How to create a pop-up window in asp.net mvc?

前端 未结 4 751
日久生厌
日久生厌 2021-02-05 12:09

No javascript/AJAX to be used.

when clicked on the hyperlink, it should open a new browser window.

相关标签:
4条回答
  • 2021-02-05 12:42

    If you're not using javascript, you need to use the target="_blank". But to do it in a cleaner mvc fashion, do:

    <%= Html.ActionLink("Click me", "ActionName", null, new {target="_blank"}) %>
    
    0 讨论(0)
  • 2021-02-05 12:44

    Basic HTML Anchor Element:

    <a href="http://www.w3schools.com/"
    target="_blank">Visit W3Schools!</a>
    

    ASP.NET WebForms HyperLink Element:

    <asp:HyperLink ID="HyperLink1" runat="server" Target="_blank">HyperLink</asp:HyperLink>
    

    ASP.NET MVC Style:

    <%= Html.ActionLink<HomeController>(c => c.Index(), "Click me", new { target = "_blank" }) %>
    

    All three open a new tab, would that suit your needs?

    0 讨论(0)
  • 2021-02-05 13:02

    If your question is - How can I create pop-up window in 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.

    You noticed that the solutions above are all 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.

    0 讨论(0)
  • 2021-02-05 13:03
    <A Href="page.html" target="_blank">Link text </A>
    

    The target="_blank" is the specific part you need.

    Alternatively you could use target="new". Here's an article that describes how the two behave differently.

    0 讨论(0)
提交回复
热议问题