使用MVC4生成模态jQuery部分视图不起作用 [英] Generating a modal jQuery partial view with MVC4 does not work
问题描述
我喜欢MVC4管理新登录屏幕的方式:可以显示模式对话框.
I like the way MVC4 manage the new logon screen: it is possible to have a modal dialog showed.
我试图在相同的解决方案中为另一个视图重现相同的行为.但这不起作用,因为 Request.QueryString ["content"] 为空.我不知道为什么实际上,发生欺骗的地方有一个称为ContextDependentView的操作方法(由MVC模板生成).在这里:
I tried to reproduce the same behavior in the same solution for another view. But it doesn't work because Request.QueryString["content"] is null. I don't know why. In fact, there is an action method called ContextDependentView (generated by the MVC template) where the trick occurred. Here it is:
private ActionResult ContextDependentView()
{
string actionName = ControllerContext.RouteData.GetRequiredString("action");
if (Request.QueryString["content"] != null)
{
ViewBag.FormAction = "Json" + actionName;
return PartialView();
}
else
{
ViewBag.FormAction = actionName;
return View();
}
}
如果 Request.QueryString ["content"] 的值不为null,则显示局部视图(模态jQuery),否则为经典视图.
If the value of Request.QueryString["content"] is not null then we display a partial view (modal jQuery) otherwise it is a classic view.
有人可以帮助我了解为什么它不起作用吗?
Can someone help me understand why this is not working?
PS:另一个线程已经存在,但没有任何解决方案.
PS: another thread already exists but without any solution.
推荐答案
登录和注册链接绑定到AjaxLogin.js中的单击处理程序,然后在loadAndShowDialog中添加content = 1
The login and register links are bound to a click handler in AjaxLogin.js which then adds content=1 in loadAndShowDialog
这篇关于使用MVC4生成模态jQuery部分视图不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!