the code:
<% using (Ajax.BeginForm("GetResourcesByProject", "CreateRequest", new AjaxOptions { UpdateTargetId = "ResourceListDiv"})) { Response.Write(Html.DropDownList("SelectProject", Model.ProjectList, "Select Project", new { onchange = "this.form.submit();" })); } %>
When I start the page, I get the correct controller action to start with the correct data in the form collection:
public ActionResult GetResourcesByProject(FormCollection formCollection) { var resourceModels = (from project in POTSModel.ProjectList where project.Id == Convert.ToInt32(formCollection["SelectProject"]) select project).First().Resources; return PartialView("ResourceList", resourceModels); }
It works great with Ajax.ActionLink as follows:
<%= Ajax.ActionLink("Select", "GetResourcesByProject", "CreateRequest", new { projectId = item.Id }, new AjaxOptions { UpdateTargetId = "ResourceListDiv" })%>
When a message occurs, I switch to a new page instead of staying on an existing page and updating the contents of the div.
Thanks.
drop-down-menu asp.net-mvc ajax.beginform
Tyler
source share