jQuery Mobile modal dialog window doesn't submit correct with Begin.Ajax

jQuery Mobile modal dialog window doesn't submit correct with Begin.Ajax

i have some problems with a modal dialog in my jQuery mobile / mvc 2 application. when submitting the modal dialog the returned view opens in main window and not as expected in modal popup.

my modal dialog is implemented as an aspx page that looks like this:

  1. <%@ Page Title="" Language="C#" Inherits="System.Web.Mvc.ViewPage<Models.ContactData>" %> <div data-role="page" id="Contact"> <div data-role="header" data-theme="a"> <h1>Contact</h1> </div> <div data-role="content" data-theme="a"> <% Html.EnableClientValidation(); %> <% using (Ajax.BeginForm("sendContact", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "Contact" })) { %> <%= Html.ValidationSummary()%> <h1>Data</h1> <p>Name: <%: Html.TextBoxFor(m => m.userName) %> <%: Html.ValidationMessageFor(m => m.userName) %></p> <p>eMail: <%: Html.TextBoxFor(m => m.userEmail) %> <%: Html.ValidationMessageFor(m => m.userEmail) %></p> <input type="submit" value="Send" /> <% } %> </div> 

in my main view i load this modal at the end of the site (after the closing div of the data-role=page-div with:

  1. <% Html.RenderPartial("Contact", Model.Contact); %> 

from the mein view the modal dialog is opened via

  1. <a href="#Contact" data-rel="dialog" data-transition="pop" data-role="button">Contact me</a> 

the model looks like this:

  1. public class ContactData { [Required(ErrorMessage = "Name is missing.")] public string userName { get; set; } [Required(ErrorMessage = "Email is missing.")] public string userEmail { get; set; } } 

my controller action sendContact looks like this:

  1. [HttpPost] public ActionResult sendContact(ContaktData contactData) { if (!ModelState.IsValid) return PartialView("Contact", contactData); //send mail logic return PartialView("Success"); } 

clicking the button 'Contact me' open the modal dialog absolutely correct, but after submitting a form with no data, the returned partial view is opened in main window with validated controls (the validation errors appear), but the modal dialog disapeared. any ideas how to solve this problem???

thanks for all your ideas and suggestions!