使用@Ajax.ActionLink弹出表单
我想使用 @Ajax.ActionLink 弹出一个表单,所以我在我的 cshtml 页面中执行了此操作:
@Ajax.ActionLink("click ", "AddToMembers", new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })
<div id="result" style="display:none;"></div>
并添加此脚本:
<script type="text/javascript">
$(document).ready(function () {
$("#result").dialog({
autoOpen: false,
title: 'Title',
width: 500,
height: 'auto',
modal: true
});
});
function openPopup() {
$("#result").dialog("open");
}
</script>
在我的控制器中添加了此功能:
[HttpGet]
public PartialViewResult AddToMembers()
{
return PartialView();
}
但是当我单击表单中的“单击”时,新页面将在其中打开浏览器。不在我的弹出表单中 有什么问题吗???
i want to use @Ajax.ActionLink to popup a form so i did this in my cshtml page :
@Ajax.ActionLink("click ", "AddToMembers", new AjaxOptions { HttpMethod = "GET", UpdateTargetId = "result", InsertionMode = InsertionMode.Replace, OnSuccess = "openPopup" })
<div id="result" style="display:none;"></div>
and add this script :
<script type="text/javascript">
$(document).ready(function () {
$("#result").dialog({
autoOpen: false,
title: 'Title',
width: 500,
height: 'auto',
modal: true
});
});
function openPopup() {
$("#result").dialog("open");
}
</script>
in my controller added this function :
[HttpGet]
public PartialViewResult AddToMembers()
{
return PartialView();
}
but when i click on the "click" in my form the new page open in the browser . not in the my popup form
what's the problem ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您忘记在页面中包含以下脚本:
此脚本用于 AJAX 化由
Ajax.ActionLink
帮助器生成的锚点。另外,如果您正在使用 jQuery 对话框,请确保您已引用 jQuery UI:I suspect that you forgot to include the following script to your page:
This script is used to AJAXify the anchor generated by the
Ajax.ActionLink
helper. Also sinde you are using jQuery dialog make sure you have referenced jQuery UI: