我试图让这个http://blog.stevehorn.cc/2009/06/rendering-modal-dialog-with-aspnet-mvc.html与 MVC 3 一起工作。
我是 ASP.Net MVC 的新手,最近开始了一个 MVC 3 项目。当用户单击我的 _Layout.cshtml 文件中的登录超链接时,我想显示一个模式登录表单:
<a href="#" id="LogIn">Log In</a>
我在以下位置创建了一个登录视图 Areas/Auth/Views/Auth/Login.cshtml
我已将以下脚本添加到我的 _Layout.cshtml 文件中:
<script type="text/javascript">
$(document).ready(function ()
{
$("#LogIn").click(function (event)
{
$.get(
"~/Areas/Auth/Views/Auth/Login" ,
function (htmlResult)
{
$("#LoginModal").remove(); //In case this is the second time they've requested the dialog.
$("#container").append(htmlResult);
$("#LoginModal").dialog();
}
);
return false; //To keep the default behavior of the anchor tag from occuring.
});
</script>
并向我的 AuthController 添加了 PartialViewResult:
public PartialViewResult LoginView()
{
return PartialView("Login");
}
但是,单击登录链接时没有任何反应。任何关于这样做的好的 MVC 3 教程的建议或链接,将不胜感激。
谢谢!