Prajyot Bhandari
Prajyot Bhandari

Reputation: 11

How to Open in New Tab upon SelectedIndexChanged?

protected void RedirectToLink_SelectedIndexChnaged(object sender, EventArgs e)
{
   if (ddlOtherWebsites.SelectedIndex != -1)
   {
     //Im using this code but it gives a Popup window alert to Allow it to open. 
     //I want an alternative to it so that i dont have to click allow everytime.
      DataTable dt = db.getDataTable("select * from otherwebsites where Status='1' 
                                 and id=" + ddlOtherWebsites.SelectedValue.ToString());  
     if (dt != null && dt.Rows.Count > 0)      
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow",
           "window.open('" + dt.Rows[0]["shortdescp"].ToString() + "','_newtab');",true);
    }
  }
}

Upvotes: 1

Views: 408

Answers (1)

Kiran Varsani
Kiran Varsani

Reputation: 587

There is no available option like _newtab or _tab. You need to use _blank to open a new tab.

protected void RedirectToLink_SelectedIndexChnaged(object sender, EventArgs e)
{
    if (ddlOtherWebsites.SelectedIndex != -1)
    {
        DataTable dt = db.getDataTable("select * from otherwebsites where Status='1' and id=" + ddlOtherWebsites.SelectedValue.ToString());
        if (dt != null && dt.Rows.Count > 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('" + dt.Rows[0]["shortdescp"].ToString() + "','_blank');",true);
        }
    }
}

Upvotes: 1

Related Questions