【发布时间】:2013-11-20 08:39:25
【问题描述】:
我有两种操作方法。 Get 方法返回部分视图,用户必须填写一些表单。
当我按下这个表单上的按钮时调用 Post 方法,它也返回一个局部视图。但是 post 方法总是在新窗口中打开部分视图。
但我需要 post 方法来加载像 PARTIAL 这样的部分视图,而不是在新窗口中
你有什么想法吗?
[HttpGet]
public PartialViewResult EditProfile(int freelancerId)
FreelancerProfile freelancerProfile = new FreelancerProfile();
return PartialView(freelancerProfile); // EditProfile is opening in the part of window. it's ok.
}
[HttpPost]
public PartialViewResult EditProfile(FreelancerProfile freelancerProfile)
{
repository.SaveProfileChangesFreelancer(freelancerProfile);
return PartialView("EditProfile", freelancerProfile); //EditProfile is opening in the new window. it's trouble
}
【问题讨论】:
-
您应该通过 javascript 调用 PartialViewResult 发布方法,并使用 javascript 或 jquery 在您的页面中呈现结果
标签: asp.net-mvc asp.net-mvc-4 http-post asp.net-mvc-partialview