• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 789
  • Last Modified:

Html.DisplayFor -- Hide per User Request, ASP.net MVC4

Does anyone have some ASP.net MVC4 "commandButton"
code that does something like the below step #2 ?

 1. page displays with all values below
 2. user decides they don't want to see the below
      "@Html.DisplayFor(modelItem => item.DR)"
     so they click a "HIDE/SHOW" button
 3. this field disappears, but all others remain visible
@foreach (var item in Model) {
            @Html.DisplayFor(modelItem => item.IFSWO)
            @Html.DisplayFor(modelItem => item.DR)
            @Html.DisplayFor(modelItem => item.RefDRNo)
            @Html.DisplayFor(modelItem => item.ProjectID)
1 Solution
Jeroen TimmermansCommented:
I'll assume item.DR is a boolean, you can add
@{end if}

Open in new window

Around the bits you want to hide.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now