ozsenegal
ozsenegal

Reputation: 4143

Asp.net MVC Visible/hide

That's a simple task in ASP.NET WebForms:If you want to show/hide a control all you need to do is set "Visible=true" or "Visible=false".

However,i dont know how to accomplish that in MVC.I have a DIV in my view that needs to show/hide,depending validation on server.

<div class="divWarning">
Test
</div>

I need to show or hide it dynamic,but needs to be controlled by server.

Any ideias?

Upvotes: 5

Views: 7519

Answers (1)

jwsample
jwsample

Reputation: 2411

<% if(Model.ShowYourDiv){ %>

   <div class="divWarning">
   Test
   </div>

<% } %>

The div will only show when the ShowYourDiv property is true.

Upvotes: 11

Related Questions