How do I use Target=_blank on a response.redirect?

后端 未结 12 1938
梦谈多话
梦谈多话 2020-12-10 16:12

I do not necessarily have to use response.redirect, but that is what I had. I would like to open the selected link in a new window. How do I do that?

context         


        
12条回答
  •  庸人自扰
    2020-12-10 16:31

    If you are just handling navigation you can try a ASP:Hyperlink control rather than a button, that way the target is specified for the browser when the page is rendered:

    protected void Page_Load (object sender, EventArgs e)
    {
        lnkViewPage.NavigateURL = sURL;
        lnkViewPage.Target = "_blank";
    }
    

    Of course it is more polite to leave .Target alone because in this case the hyperlink could be right clicked and "open in new page/tab" would be available from the context menu.

提交回复
热议问题