how to open a page in new tab on button click in asp.net?

前端 未结 16 2182
情书的邮戳
情书的邮戳 2020-11-29 07:32

I want to open a page in new tab of browser on button click.

I have searched a lot on google but i couldn\'t find anything.

Here is my button.



        
16条回答
  •  情书的邮戳
    2020-11-29 07:52

    You can add to your button OnClientClick like so:

    
    

    This will change the current form's target for all buttons to open in new tab. So to complete the fix you can then use 2 approaches:

    1. For any other button in this form, add to client click a "reset form target" function like so:
    function ResetTarget() {
       window.document.forms[0].target = '';
    }
    
    1. Add the same code inside the function inside a setTimeout() so the code will reset the form's target after few moments. See this answer https://stackoverflow.com/a/40682253/8445364

提交回复
热议问题