RadhaKrishnaKiJaya
asked on
Make a dropdown list invisible in C# MVC
Hi Experts,
I want to make the @Html.CountryDropDownList invisible. Please help.
Thanks in advance.
I want to make the @Html.CountryDropDownList invisible. Please help.
Thanks in advance.
<div class="spacer-15">
<fieldset id="fieldsetShippingAddress">
@Html.LabelForRequired(m => Model.Company, T("Organization name").Text)
@Html.TextBoxFor(m => Model.Company)
@Html.LabelForRequired(m => Model.Address1, T("Address line 1").Text)
@Html.TextBoxFor(m => Model.Address1)
@Html.LabelForRequired(m => Model.Address2, T("Address line 2").Text)
@Html.TextBoxFor(m => Model.Address2)
@Html.LabelForRequired(m => Model.City, T("City").Text)
@Html.TextBoxFor(m => Model.City)
@Html.LabelForRequired(m => Model.State, T("State/Province").Text)
<span class="wide-select-ie">
@*@Html.StateDropDownList("State", Model.State, T("Select one").Text)*@
@Html.StateDropDownList("StateId", Model.Country, Model.State, T("Select one").Text)
</span>
@Html.LabelForRequired(m => Model.PostalCode, T("ZIP/Postal code").Text)
@Html.TextBoxFor(m => Model.PostalCode)
@Html.LabelForRequired(m => Model.Country, T("Country"))
@Html.CountryDropDownList("Country", Model.Country, new { onchange = "resetSelect('#State');", @class = "special-dropdown", title = T("Please specify") })
</fieldset>
</div>
public static MvcHtmlString CountryDropDownList(this HtmlHelper htmlHelper,
string name,
string selectedValue,
object htmlAttributes) {
var countriesSelectList = GetCountriesSelectList(htmlHelper, selectedValue);
return htmlHelper.FacetDropDownList(name, countriesSelectList, htmlAttributes);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you for giving me the idea. The exact code didn't work but I put the drop down in a Div and applied the style you suggested and then it worked!!
<div style = "display: none">
@Html.LabelForRequired(m => Model.Country, T("Country"))
@Html.CountryDropDownList(
dropdown", title = T("Please specify")})
</div>