How to open page in new tab using the response. redirect at asp.net

后端 未结 8 2104
太阳男子
太阳男子 2021-01-03 23:42

I want to open a new tab or a new page by using Response.Redirect in a button click handler. I\'m using a query string to pass some values. How can I open he pa

相关标签:
8条回答
  • 2021-01-04 00:07

    Simple solution is here.

    Edit your html button element and add attribute OnClientClick="target ='_blank';".

    <asp:Button ID="myButton" runat="server" CssClass="btn1"
                OnClick="btnSave_Click" OnClientClick="target ='_blank';" />
    

    Then in btnSave_Click

    protected void btnSave_Click(object sender, EventArgs e) { 
        Response.Redirect(url);
    }
    
    0 讨论(0)
  • 2021-01-04 00:09

    A redirect is always in the same page as where you came from, you can't open a new window from a redirect call.

    I would suggest to inject some javascript code in the client to open the new page on reload, or change to a control that can open to a new page, like a LinkButton with the right Target attribute.

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