Reputation: 11480
I've got a traditional User Control, I have the following structure:
<asp:Content id="ContentBody" runat="server" ContentPlaceHolderId="MainContent">
<Core:AccountApplication id="uxAccountApplication" runat="server" />
</asp>
Inside the User Control I have a traditional:
<form id="AccountForm">
<input type="text" id="txtCompany" name="Company" />
<input type="submit" id="btnSubmit" />
</form>
The problem occurs when I call $('#AccountForm').serialize();
the request is constantly empty, nothing is serialized. If I do $('form').serialize();
it does serialize, but it also grabs all of the Web-Form ViewState
rendering. Which requires some dubious approaches to correct.
Is there a better way to tackle?
Upvotes: 0
Views: 77
Reputation: 11480
After the answer received where it was denoted that the form element is removed, I verified and the entire form was indeed removed. So I did the following:
<div class="Application-Container">
<!-- All my form inputs -->
</div>
Wrapped them into a container, then I used jQuery to wrap the container into a form.
$('.Application-Container').wrap('<form id="AccountForm"></form>');
Now when you submit, it will rewrap into the form, then I can call $('#AccountForm').serialize()
and it will correctly build my form data.
Upvotes: 0
Reputation: 96571
Nested forms are not allowed in ASP.NET (see this question for example).
Your <form id="AccountForm">
element will be removed by ASP.NET (look at the generated HTML to confirm that).
Upvotes: 1