How To: Open a pop-up window using dropdownlist

To open pop-up window using <asp:dropdownlist..>

VB.NET

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
 Response.Write("<script>window.open('" + DropDownList1.SelectedValue + "');</script>")
End Sub

C#

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("<script>window.open('" + DropDownList1.SelectedValue + "');</script>");

To pop-up using client-side event

VB.NET

DropDownListID.Attributes("onchange") = "<open pop up here>"

C#

DropDownListID.Attributes("onchange") = "<open pop up here>";

5 Comments

  • DropDownListID.Attributes("onchange") = "";

    I want to use this script, but I do not know where to inject this script in ASPX page in ( source/desgin) everywhere I am getting error)

  • i can open a popup window using above coding.. but wt abt d contain of popup...in popup window thr is an error dat requested url could not be found....tel me plz abt dat.

  • Hi,

    my question is how to create a pop up wondow, I will have a link, TAKE A TEST, then a new pop up wondow should open, but not like the one this code does:

    Take a test

    in this code the wondow is derived from the master page. I want something new, any ideas?
    I'm using ASP.NET 2.0 and VB

    Thanks


  • Hello!!! weblogs.asp.net is one of the most outstanding resourceful websites of its kind. I take advantage of reading it every day. Keep it that way.

  • Thanks a lot! We invested a lot more than an hour searching for my. htaccess file and lastly observed the item due to your own personal story!

Comments have been disabled for this content.