?
Solved

Open new page after choosing drop down list selection

Posted on 2009-07-05
7
Medium Priority
?
313 Views
Last Modified: 2013-11-26
I have an asp.net vb page that has a form.  Within the form, is  a dropdown list that asks if a person has more information to include.  The drop downlist has the following options: "Yes" and "No".  I would like to launch a new webpage "moreinfo.aspx" if the answer "Yes" is selected.  I would like the page to be on top of the form page. Can someone help?
0
Comment
Question by:OB1Canobie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 3

Expert Comment

by:sandip-mishra
ID: 24782028
Hi .... Try this, it works fine for me...

aspx.....

<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true">
            <asp:ListItem>Select</asp:ListItem>
            <asp:ListItem>Yes</asp:ListItem>
            <asp:ListItem>No</asp:ListItem>
        </asp:DropDownList>

aspx.cs

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (DropDownList1.SelectedValue == "Yes")
        {
            String s = @"<script language='javascript' type='text/javascript'>";
            s += "window.open('http://www.google.co.in');";
            s += "</script>";
            Page.RegisterStartupScript("OpenWindow", s);
        }
    }
0
 
LVL 10

Expert Comment

by:Espavo
ID: 24782672
The way that I would do this is by using a ModalPopUp (instead of opening a new window)...
The form would have to be a part of the original page though...
0
 

Author Comment

by:OB1Canobie
ID: 24785538
sandip-mishra,

what language is your example written in?  This does not appear to be vb.  Can you rewrite in vb?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:sandip-mishra
ID: 24791004
hi...

here is the VB coding....

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
       If DropDownList1.SelectedValue = "Yes" Then
            Dim s As [String] = "<script language='javascript' type='text/javascript'>"
            s += "window.open('http://www.google.co.in');"
            s += "</script>"
            Page.RegisterStartupScript("OpenWindow", s)
        End If
   End Sub


I have converted the C# code to VB code. Hope it works for you too.

Regards

Sandip Mishra
0
 

Author Comment

by:OB1Canobie
ID: 24795817
sandip-mishra:
I'm getting an error with the vb code above.  The error is occuring on the line "Page.RegisterStartupScript("OpenWindow", s)",  any ideas of how to fix?

Warning      1      'Public Overridable Sub RegisterStartupScript(key As String, script As String)' is obsolete: 'The recommended alternative is ClientScript.RegisterStartupScript(Type type, string key, string script). http://go.microsoft.com/fwlink/?linkid=14202'.
0
 
LVL 3

Accepted Solution

by:
sandip-mishra earned 2000 total points
ID: 24800536
hi... try with t his... its working  fine wit h me... I generally write my codes in C#.  SO had just converted the C# code into VB using a tool and had executed the code. It is working fine for me. Hope it works for u too... :)

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
        If DropDownList1.SelectedValue = "Yes" Then
            If (Not Me.IsStartupScriptRegistered("Startup")) Then

                Dim s As [String] = "<script language='javascript' type='text/javascript'>"
                s += "alert('hi');window.open('http://www.google.co.in');"
                s += "</script>"
                Me.RegisterStartupScript("Startup", s)
            End If
        End If
    End Sub
End Class

Regards

Sandip Mishra
0
 

Author Closing Comment

by:OB1Canobie
ID: 31599936
This code is great.  Thanks for the help.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question