suresh

suresh

  • NA
  • 293
  • 0

How to Open new tab when we click on LinkButton

Oct 9 2012 2:25 PM
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)