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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -