I'm working a simple modal popup.My goal is to send dialog's information to another view. My index view below.
<button id="modal-opener">Open</button>
<div id="dialog-modal">
@using (Ajax.BeginForm("Index",new AjaxOptions{UpdateTargetId = "ID",HttpMethod = "Post",OnSuccess = "onSuccess"}))
{
<div>
<fieldset>
<legend>Acount Information</legend>
<div id="editor-label">
@Html.LabelFor(a=>a.FirstName)
</div>
<div id="editor-field">
@Html.TextBoxFor(a=>a.FirstName)
@Html.ValidationMessageFor(a=>a.FirstName)
</div>
<div id="editor-label">
@Html.LabelFor(a=>a.LastName)
</div>
<div id="editor-field">
@Html.TextBoxFor(a=>a.LastName)
@Html.ValidationMessageFor(a=>a.LastName)
</div>
<p>
<input type="submit" value="submit"/>
</p>
</fieldset>
</div>
}
</div>
And my _Layout.cshtml is below:
<script>
$(function() {
$("#dialog-modal").dialog({
autoOpen: false,
width: 300,
height: 250,
show: {
effect: "blind",
duration:1000
},
hide: {
effect: "explode",
duration:1000
}
});
$("#modal-opener").click(function() {
$("#dialog-modal").dialog("open");
});
});
function onSuccess() {
$("#dialog-modal").dialog("close");
}
</script>
And my controller is below ,so I want to send FirstName and LastName to details view
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(Person person)
{
return RedirectToAction("Details",person);
}
public ActionResult Details(Person person)
{
return View(person);
}