c# - check the selected value in drop down list -
c# - check the selected value in drop down list -
i have next drop downwards list. how can check selected value before saving info module ? because want utilize selected value in setting values of neighborhood's drop downwards list.
@html.dropdownlistfor(model => model.city, new selectlist( new list<object>{ new { value = "abha" , text = "abha" }, new { value = "al qunfudhah" , text = "al qunfudhah" }, new { value = "al-kharj" , text = "al-kharj"}, new { value = "al-ahsa" , text = "al-ahsa" }, new { value = "buraidah" , text = "buraidah"}, new { value = "dammam" , text = "dammam" }, new { value = "ha'il" , text = "ha'il"}, new { value = "hafar al-batin" , text = "hafar al-batin" }, new { value = "jazan" , text = "jazan"}, new { value = "jeddah" , text = "jeddah"}, new { value = "jubail" , text = "jubail"}, new { value = "khobar" , text = "khobar"}, new { value = "khamis mushait" , text = "khamis mushait"}, new { value = "mecca" , text = "mecca"}, new { value = "medina" , text = "medina"}, new { value = "najran" , text = "najran"}, new { value = "qatif" , text = "qatif"}, new { value = "riyadh" , text = "riyadh"}, new { value = "tabuk" , text = "tabuk"}, new { value = "ta'if" , text = "ta'if"}, new { value = "yanbu" , text = "yanbu"} },"value", "text", "jeddah")) @html.validationmessagefor(model => model.city) </div> </div>
with jquery, can try
$('#city').val(); if not using jquery, vanilla javascript way be
var element = document.getelementbyid("city"); var strval = element.options[element.selectedindex].value; c# asp.net asp.net-mvc razor model-view-controller
Comments
Post a Comment