HTML.Listbox in MVC not showing in FormsCollection
I have an ASP.NET MVC application where I have an HTML.Listbox where a user can add items to it in a web page. It looks like this.
<p>
<label for="groups">Grupper:</label>
<%= Html.ListBox("RoleGroups", (Model != null ? new SelectList(Model.RoleGroups) : new SelectList(new List<BL.Portal.Domain.Model.RoleGroup>(){})))%>
<%= Html.ValidationMessage("RoleGroups")%>
<br />
<input type="button" id="btnRemoveRoleGroup" name="brnRemoveRoleGroup" value="Ta bort gruppen" />
<input type="button" id="btnAddRoleGrop" name="btnAddRoleGrop" href="#dialogAddRoleGroup" value="Lägg till en grupp" />
</p>
And in the controller I get this kind of information.
[RequiresRole(RoleToCheckFor = RoleEnum.UserCreate)]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult CreateEdit(Model.User user, bool newUser, string confirmedpassword)
But in my user the RoleGroups properties are always Null, so I check Request.Form.AllKeys and can't find the key: RoleGroups. So I think the Html.Listbox information is never sent when I postback!
What did I miss?
+1
a source to share