I am using ASP .NET to display a JQuery dialog that has a few input fields. I now need these fields to submitted to an action method like how a normal HTML submit button would work on an ASP .NET MVC application. How do I accomplish this?
- This is my form data:
All form fields are required.
<%Html.BeginForm('AddUser', 'User'); %> <fieldset> <label for='name'>Name</label> <input type='text' name='name' id='name' /> <label for='email'>Email</label> <input type='text' name='email' id='email' value='' /> <label for='password'>Password</label> <input type='password' name='password' id='password' value='' /> </fieldset> <%Html.EndForm(); %>
‘
- And this is my script:
$(function() { $('#dialog').dialog({ bgiframe: true, height: 400, width: 600, modal: true, buttons: { 'Create user account': function() { $(this).dialog('close'); }, Cancel: function() { $(this).dialog('close'); } } }); });
Add a line to your code that submits the form:
You can set the ID by giving the
Html.BeginForm()method an argument forhtmlAttributes(typeobjectif I remember the structure correctly – look for it in the overload methods in IntelliSense).