title: passing data from jquery dialog to asp.net mvc controller
body: <p>How exactly should data from the jquery dialog be passed to the Controller? I'm unsure what to put for the data (see Index.cshtml code)</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public ActionResult CreateUser() {
          return PartialView("_Create", new RegisterModel());
      }
  
  [HttpPost]
  public ActionResult CreateUser(RegisterModel user) {
      //...
  }
  </code></pre>
  
  <p><strong>Index.cshtml</strong></p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function () {
      $('#dialog').dialog({
          //...dialog information
          open: function(event, ui) {
              $(this).load('@Url.Action("CreateUser")');
          },
          buttons: {
              "Submit": function () {
                  $.ajax({
                      url: 'Users/CreateUser',
                      type: 'POST',
                      data: /* What is passed here? */,
                  });
              }
          }
      });
  
      $('#btnCreate').click(function (e) {
          e.preventDefault();
          $('#dialog').dialog('open');
      });
  
  });
  &lt;/script&gt;
  
  @Html.ActionLink("Create New User", "CreateUser", null, new { id= "btnCreate" })
  &lt;div id="dialog" title="Create User" style="overflow: hidden;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>---Edit---
  here's the model that's being called from the open function</p>
  
  <p><strong>Model</strong></p>
  
  <pre><code>public class RegisterModel {
      [Required]
      [Display(Name = "User name")]
      public string UserName { get; set; }
  
      [Required]
      [DataType(DataType.EmailAddress)]
      [Display(Name = "Email address")]
      public string Email { get; set; }
  
      [Required]
      [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
      [DataType(DataType.Password)]
      [Display(Name = "Password")]
      public string Password { get; set; }
  
      [DataType(DataType.Password)]
      [Display(Name = "Confirm password")]
      [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
      public string ConfirmPassword { get; set; }
  
      [Required]
      [Display(Name = "Roles")]
      public string RolesId { get; set; }
      public IEnumerable&lt;SelectListItem&gt; RolesItem {
          get { return new SelectList(Roles.GetAllRoles()); }
      }
  }
  </code></pre>
  
  <p><strong>partial view</strong></p>
  
  <pre><code>@model MvcApp.Models.RegisterModel
  
  @{
      ViewBag.Title = "Register";
  }
  
  &lt;h2&gt;Create a New User&lt;/h2&gt;
  &lt;p&gt;
      Passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length.
  &lt;/p&gt;
  
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"&gt;&lt;/script&gt;
  
  &lt;div id="CreateModel"&gt;&lt;/div&gt;
  
  @using (Html.BeginForm()) {
      @Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.")
      &lt;div&gt;
          &lt;fieldset&gt;
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td&gt;@Html.LabelFor(m =&gt; m.UserName)&lt;/td&gt;
                      &lt;td&gt;@Html.EditorFor(m =&gt; m.UserName)&lt;/td&gt;
                      &lt;td&gt;@Html.ValidationMessageFor(m =&gt; m.UserName)&lt;/td&gt;
                  &lt;/tr&gt;
                  ... more fields... 
  
              &lt;/table&gt;
          &lt;/fieldset&gt;
      &lt;/div&gt;
  }
  </code></pre>