4
Answers

How to Open new tab when we click on LinkButton

suresh

suresh

12y
16.6k
1
Hi,

i am getting value from database and assigned to that LinkButton.
When i clicked that link button, it should open in new tab insted of new window.

 <asp:LinkButton runat="server" ID="blCompurl" OnClick="OpenCompUrl"
                                                                        CssClass="BodyLink2"></asp:LinkButton>

blCompurl.Text="http://www.google.com"

 protected void OpenCompUrl(Object sendder, EventArgs e)
        {
            LinkButton btnComp = (LinkButton)sendder;
            String Url = btnComp.Text;
            //ScriptManager.RegisterStartupScript(this,this.GetType(), "Open", "window.open('" + Url + "');", true);
            Response.Write("<script language='javascript'>window.open('" + Url + "','_blank','');");
            Response.Write("</scr" + "ipt>");
           

        }

it's opening in new window.
Answers (4)