[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Open new page after choosing drop down list selection

Posted on 2009-07-05
7
Medium Priority
?
314 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

656 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