c# - How to get disabled DropDownList control value to controller -
work on asp.net mvc5.my project dropdownlist work problem arise when disabled dropdownlist control can not value in controller.
my razor syntax bellow:
<div class="form-group"> @html.labelfor(m => m.productname, new {@class = "col-md-3 control-label"}) <div class="col-md-3"> @html.dropdownlist("productid", null, "select product", new {@placeholder = "select product", @class = "form-control", @disabled = "disabled" }) </div> </div>
my controller syntax fill above dropdownlist
private void loadproductsinviewdata(object selectedvalue = null) { var datas = productrepository.getall().orderby(p => p.name); viewbag.productid = new selectlist(datas, "productid", "name", selectedvalue); }
why in controller create/edit event can not dropdownlist value? note:i know it's disabled control default behavior,i try use hidden column this.problem how hidden column used approach.
you can use jquery retrive value of selected item of droplist disabled in case, using
var dropdownvalue=("#id_of_u_dropdownlist").val()
and can send dropdownvalue variable contains value of disable dropdown list controller.
Comments
Post a Comment