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

前端 未结 16 1883
情书的邮戳
情书的邮戳 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:57

    You could use window.open. Like this:

    protected void btnNewEntry_Click(object sender, EventArgs e)
    { 
       Page.ClientScript.RegisterStartupScript(
       this.GetType(),"OpenWindow","window.open('YourURL','_newtab');",true);
    }
    
    0 讨论(0)
  • 2020-11-29 07:57

    Add_ supplier is name of the form

    private void add_supplier_Load(object sender, EventArgs e)
    {
        add_supplier childform = new add_supplier();
        childform.MdiParent = this;
        childform.Show();
    }
    
    0 讨论(0)
  • 2020-11-29 07:58

    Just had the same problem. Client-side wasn't appropriate because the button was posting back information from a listview.

    Saw same solution as Amaranth's on way2coding but this didn't work for me.

    However, in the comments, someone posted a similar solution that does work

    OnClientClick="document.getElementById('form1').target ='_blank';"
    

    where form1 is the id of your asp.net form.

    0 讨论(0)
  • 2020-11-29 07:59

    Use JavaScript for the main form / Button click event. An example is:

    Context.Response.Write("<script language='javascript'>window.open('AccountsStmt.aspx?showledger=" & sledgerGrp & "','_newtab');</script>")
    
    0 讨论(0)
  • 2020-11-29 08:03

    Try This

    <a href="#" target="_blank">Link</a>
    
    0 讨论(0)
  • 2020-11-29 08:03

    In vb.net either on button click or on link button click, this will work.

    System.Web.UI.ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "openModal", "window.open('CertificatePrintViewAll.aspx' ,'_blank');", True)
    
    0 讨论(0)
提交回复
热议问题