[ACCEPTED]-Setting visibility of a textbox in MVC3 Razor view engine-asp.net-mvc-2
Accepted answer
This will change the display type based 2 on your bool Model.EnableCompanyName :)
Hope 1 it helps!
@{
String displayMode = (Model.EnableCompanyName) ? "inline" : "none";
@Html.TextBox("CompanyName", "", new { style = "display:" + displayMode + ";" })
}
It's nothing to do with razor as such. visible
is 3 not a valid attribute for an input
element (which 2 is what Html.TextBox will be generating). You 1 need
@Html.TextBox("CompanyName", "", new { style = "display:none;" })
See this example here:
Updated:
@Html.TextBox("CompanyName", "", new { style = Model.EnableCompanyName ? "display:inline" : "display:none" })
0
Try this:
@Html.TextBox("CompanyName", "", new {Style= Model.EnableCompanyName ? "visibility:visible" : "visibility:hidden" })
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.