Hide a DropDownList in MVC4
I have a Simple query to ask..
I have a DropdownList,and it holds data which depends on values from
DATABASE.
Now their can be 2 scenario:-
1)- DropdownList holds value(Not empty) 2)-DropdownList Doesnt hold
values(Empty)
Now what I want is,I want to Hide the DropdownList and the LABEL(Select
UserName) if it EMPTY..I hope am clear..!!
I tried This to hide DropDownList but it dint Work so How Can I hide both
the Label and the DropDownList-
<label>
Select UserName :</label>
@if (@ViewBag.UserName.Items.Count == 0)
{
<div id="uniform-undefined" class="selector"
style="margin-right: 60px; margin-left: 10px;">
@Html.DropDownList("UserName", null, new {
@visible= false })
</div>
}
No comments:
Post a Comment