c# - Working with Dropdowns in MVC 5 -
i need dropdown inaccessible (in can visible or not, preferably invisible). approach take?
i’m using c#, asp.net mvc 5, , razor syntax.
thanks in advance answers.
this bit abstract since you're asking in general sense. in razor, i'd evaluate condition determines if should shown or not , within "if" block, put code build dropdown.
@if (showdropdown){ @html.dropdownlistfor(model => model.myfield, myselectlist) } else { @html.hiddenfor(model => model.myfield) }
if want value of myfield stick around when post form, use hidden field value when dropdown supposed invisible.
Comments
Post a Comment