ASP.Net MVC 3 控制器操作并打开新窗口
我有一个控制器和一个动作。此操作是将数据保存到数据库中。现在,我希望当我提交按钮时,我的控制器执行一个操作并打开新窗口。
public ActionResult New(FormCollection collection)
{
data.Population_Code = collection["Countrys[0].CountryCode"];
data.Population_Desc = collection["Countrys[0].CountryDesc"];
data.Population_Grouping = collection["Countrys[0].CountryGroup"];
data.Population_Type = "CNTRY";
data.Population_Redudant = "N";
data.Population_Modified_At = officeCode.User_Office.ToString();
db.SaveChanges();
//example for new window
//window.open('/Report/New.aspx')
return RedirectToAction("index");
}
所以我的控制器执行一个操作并打开一个新窗口。
任何人都可以帮助我吗?
谢谢
i have a controller and an action. this action is to save data into database. and now, i want when i submit a button, my controller do an action and open new window.
public ActionResult New(FormCollection collection)
{
data.Population_Code = collection["Countrys[0].CountryCode"];
data.Population_Desc = collection["Countrys[0].CountryDesc"];
data.Population_Grouping = collection["Countrys[0].CountryGroup"];
data.Population_Type = "CNTRY";
data.Population_Redudant = "N";
data.Population_Modified_At = officeCode.User_Office.ToString();
db.SaveChanges();
//example for new window
//window.open('/Report/New.aspx')
return RedirectToAction("index");
}
so my controller do an action and open a new window.
anyone can help me ?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从技术上讲,这可以通过返回将打开新窗口的 JavaScript 来完成。
然而,大多数浏览器会杀死以这种方式调用的新窗口(即弹出窗口阻止程序)。
如果可能的话,从一开始就在新窗口中打开指向您的操作的链接会更好;
编辑
从您的操作中我可以看出,它可能是创建报告的表单;您还可以在表单上使用属性
target='_blank'
。Technically, this can be done by returning javascript that will open the new window.
However, most browsers will kill a new window called in this manner (i.e. popup blocker).
You would be better off, if possible, by opening the link to your action in a new window from the start;
Edit
I can see from your action, that it is probably a form that creates the report; you can also use the attribute
target='_blank'
on a form as well.