tags:

views:

103

answers:

1

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?

+1  A: 

Should just be

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

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

KP
that is a bit strange. is there anyway to have a control disabled but still pass it to the controller. I would like to avoid any klugy hidden fields if possible
ooo
try readonly instead of disabled http://www.w3.org/TR/html401/interact/forms.html#h-17.12.2
KP
Is <... disabled> valid markup? I think it has to be disabled="disabled"?
James S