Solved

Open new page after choosing drop down list selection

Posted on 2009-07-05
7
312 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
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
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 500 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

Industry Leaders: 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!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

705 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