Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 713
ozsenegal Avatar asked Aug 07 '10 18:08

ozsenegal


1 Answers

<% if(Model.ShowYourDiv){ %>

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

<% } %>

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

like image 172
jwsample Avatar answered Sep 17 '22 21:09

jwsample