收录日期:2020/06/02 18:43:13 时间:2009-08-07 15:38:45 标签:asp.net-mvc

in my asp.net mvc view i have a select dropdown:

<select id="userRole" name="userRole" disabled="true">

when i submit the form to the controller, i have the following code:

    [Authorize]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(FormCollection    formCollection_)
    {
        string role = formCollection_["userRole"].ToString();
}

but when i look into the formCollection object there is no key for "userRole". Any idea why this would be?

Should just be

 <select id="userRole" name="userRole" disabled>

but disabled inputs will not be part of your FormCollection "successful control"