I'm building a form in my project, but because I'm using AJAX to post the form values and multiple instances of a certain dropdown (class attribute instead of id), I'm not in need of a name attribute on my form controls.
Is there a way to create a dropdown list dynamically but explicitly omitting the name attribute without getting an exception?
@Html.DropDownList(string.Empty, Model, new { @class = "year" })
Gives me this exception:
Value cannot be null or empty. Parameter name: name
because first argument is empty.
You can do it like following.
@Html.DropDownList("aName", Model, new { Name=string.Empty, @class = "year" })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With