Hi All, I'm attempting to change the data in PartialView within my view via a dropdownlist change in the form. Now if I hit the submit button my form posts no problem and the formcollection is available, however when I try to submit via jquery on a change event the form submits alright but no formcollection
Any ideas?
This is the submission code
$(function() {
$('#ddlSelection').change(function() {
var form = $("#myForm");
var action = form.attr("action");
var serializedForm = form.serialize();
$.post(action, serializedForm, function() { alert("Finished!") });
});
});
the form is as such
<% using (Ajax.BeginForm("myForm", new AjaxOptions
{
UpdateTargetId = "divItemsList",
OnComplete = "ClearForm"
}))
{%>
<%=Html.Label("ddlFilter", "Parent Filter")%>
<%=Html.DropDownList("ddlFilter", "Please Select ...")%><br />
<fieldset>
<legend>Filter Option Details</legend>
<p>
<label for="Value">Value:</label>
<%= Html.TextBox("Value") %>
<%= Html.ValidationMessage("Value", "*") %>
</p>
</fieldset>
<%}%>
SOLUTION
Ok, should have been paying more attention, the Ajax.Beginform
tag does not give the form an id or name, I assume they regard it as uneccessary so the solution is to add the htmlattributes manually. as so ..
<% using (Ajax.BeginForm("TheAction", null, new AjaxOptions
{
UpdateTargetId = "divFilterItemsList",
OnComplete = "ClearForm"
}, new { ID = "myForm", Name = "myForm" }))
{%>