Hi
MVC 5
@Html.DropDownList("DDCA", ViewData["DDCA"] as List
i am binding values like this after genrate otp i want to disable this drop down while submit i am using
@disable="disable" but submition time dtop down value comes null i remove disable drop dwon value i will get but i want to disable and get that value while submission
Alpesh ManiyaPosted Jan 23, 2024, 2:27 PM
You may try with below steps
Add a hidden field to store the selected dropdown value:
Use JavaScript to disable the dropdown and update the hidden field during form submission:
Modify the submit button to call the JavaScript function:
This approach ensures that the dropdown is visually disabled for user interaction, but its selected value is still included in the form submission.
Tahir AnsariPosted Jan 23, 2024, 2:20 PM
If you want to disable the dropdown during form submission but still receive its selected value, you should use the
disabledattribute in the HTML and manage the disabled state using JavaScript or Razor syntax. The@disable="disable"you mentioned seems like a typo; the correct attribute isdisabled.