我正在使用部分视图和ajax的模态弹出窗口。我的观点是
<a href="Verify" id="myLink1">Verify</a>
<div id="myDialog1" title="Verify Mobile Number" style="display: none">
@{
Model.MobileVerificationModelDetails.MobileVerifyUpdateTargetID = "myDialog1";
}
@Html.Partial("_MobileVerifyPopup(MobileVerificationModel)Model.MobileVerificationModelDetails)
,部分视图是
@model werWebApplication.Models.MobileVerificationModel
@using (Ajax.BeginForm("Mobile", "Verification", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "myDialog1", OnSuccess = "onSuccess" }))
{
<fieldset>
<legend>Veify Mobile Number</legend>
<table>
<tr>
<td>@Html.LabelFor(m => m.MobileNo)</td>
<td>@Html.Encode(Model.MobileNo)@Html.ValidationMessageFor(m => m.MobileNo)</td>
</tr>
<tr>
<td>@Html.Label("Verification Code")</td>
<td>@Html.TextBoxFor(m => m.VerificationCode)</td>
</tr>
<tr>
<td> <input type="submit" value="verify" /></td>
</table>
</fieldset>
}
我的js代码是
<script type="text/javascript">
$(function () {
$("#myDialog1").dialog({
autoOpen: false,
show: 'fade',
hide: 'fade',
modal: false,
width: 400,
draggable: false,
minHeight: 200,
position: [700, 200]
$("#myLink1").click(function (e) {
e.preventDefault();
$("#myDialog1").dialog("open");
return false;
});
function onSuccess() {
$("#myDialog1").dialog("close")
}
});
</script>
我的控制器代码是
public ActionResult Mobile(MobileVerificationModel model)
{
return PartialView("_MobileVerifyPopup",model);
}
当我点击验证按钮时,我弹出窗口正在显示。但问题是我无法获得Controller中的值。有人可以帮我发布mvc4中的值
答案 0 :(得分:0)
是否有任何控制器动作被击中?
如果没有,请检查您的页面中是否有jquery.unobtrusive-ajax.js,因为Ajax.BeginForm
需要这样做。还要检查web.config中是否将UnobtrusiveJavaScriptEnabled属性设置为true