Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Lourdes Edwards   on Sep 07 In Asp.net Category.

  
Question Answered By: Raju Srinivas   on Sep 07

With adding attributes  like this - Dropdown1.Attributes.Add - you're adding client side event. And if you want to access the selected  item from client script you have to use something like Form1.selID.value.....

But as you say, you want to use SelectedIndexChanged server-side event. So you have to write your client-script in that event  - after it's started. You could add  script with RegisterClientScriptBlock like this:


private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
string strUrlToOpen = DropDownList1.SelectedItem.Value.ToString();
string strOpenWinScript = "<script language='JavaScript'>window.open('" + strUrlToOpen + "','','toolbar=0');</script>";
this.RegisterClientScriptBlock("OpenWinScript",strOpenWinScript);
}

and now, if you set AutoPostBack property od your DropDownList, on PostBack will be your script in the output and new window  will open.

Share: 

 
 
Didn't find what you were looking for? Find more on Launching a new window from a dropdown list Or get search suggestion and latest updates.


Tagged: