asp.net-mvc 如何在asp.net mvc 中创建一个弹出窗口?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1349137/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a pop-up window in asp.net mvc?
提问by kurozakura
No javascript/AJAX to be used.
没有要使用的 javascript/AJAX。
when clicked on the hyperlink, it should open a new browser window.
当点击超链接时,它应该打开一个新的浏览器窗口。
回答by Faizan S.
Basic HTML Anchor Element:
基本的 HTML 锚元素:
<a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a>
ASP.NET WebForms HyperLink Element:
ASP.NET WebForms 超链接元素:
<asp:HyperLink ID="HyperLink1" runat="server" Target="_blank">HyperLink</asp:HyperLink>
ASP.NET MVC Style:
ASP.NET MVC 风格:
<%= Html.ActionLink<HomeController>(c => c.Index(), "Click me", new { target = "_blank" }) %>
All three open a new tab, would that suit your needs?
这三个都打开了一个新标签,这是否适合您的需求?
回答by James S
If you're not using javascript, you need to use the target="_blank". But to do it in a cleaner mvc fashion, do:
如果您不使用 javascript,则需要使用 target="_blank"。但是要以更干净的 mvc 方式进行,请执行以下操作:
<%= Html.ActionLink("Click me", "ActionName", null, new {target="_blank"}) %>
回答by Cyril Gupta
If your question is - How can I create pop-up window in asp.net mvc
如果您的问题是 - 如何在asp.net mvc 中创建弹出窗口
The simple answer is : can't
简单的答案是:不能
For that matter you can't in PHP, JSP or any other server side scripting language.
就此而言,您不能使用 PHP、JSP 或任何其他服务器端脚本语言。
You noticed that the solutions above are all HTML?
你注意到上面的解决方案都是HTML吗?
The pop-up window is a domain that has to be handled client side. The server languages can spew HTML/Javsascript that have the commands to open a pop-up window. They intrinsically can't order the browser to open a window.
弹出窗口是必须在客户端处理的域。服务器语言可以生成具有打开弹出窗口命令的 HTML/Javsascript。他们本质上不能命令浏览器打开一个窗口。

