473,396 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Drop Down List and AutoPostBack. Really urgent. Thank You Very Much

Hello,

I have a Drop Down List with 3 options. I want to redirect to a new page
when an options is selected. I don't want to use a button. The redirection
should be fired when the option is selected.

I have an ASP.net / VB page with a Drop Down List named "my select" as
follows:

<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
<asp:ListItem value="www.google.com">Google</asp:ListItem>
<asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
<asp:ListItem value="www.macromedia.com">Macromedia</asp:ListItem>
</asp:DropDownList>

Then i have this script:

<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
if myselect.AutoPostBack then
Response.Redirect ("http://" &
myselect.items(myselect.SelectedIndex).Value)
end if
End Sub

</script>

I looked in the .net and tryied several options but until now i wasn't able
to make it work

This seems really simple. I don't know what is going on and i need to
deliver this as soon as possible. Can you help me?

Thank You,
Miguel

Nov 18 '05 #1
2 1552
Hi Miguel,

Use the OnSelectedIndexChanged event of dropdownlist.
<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server" OnSelectedIndexChanged="myselect_Change"> <asp:ListItem value="www.google.com">Google</asp:ListItem>
<asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
<asp:ListItem value="www.macromedia.com">Macromedia</asp:ListItem> </asp:DropDownList>
then you can write the handler as
void myselect_Change(Object sender, EventArgs e) {

}

--
Cheers!
Rajiv. R
Rajspace.Org

"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:#x**************@TK2MSFTNGP12.phx.gbl... Hello,

I have a Drop Down List with 3 options. I want to redirect to a new page
when an options is selected. I don't want to use a button. The redirection
should be fired when the option is selected.

I have an ASP.net / VB page with a Drop Down List named "my select" as
follows:

<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
<asp:ListItem value="www.google.com">Google</asp:ListItem>
<asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
<asp:ListItem value="www.macromedia.com">Macromedia</asp:ListItem> </asp:DropDownList>

Then i have this script:

<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
if myselect.AutoPostBack then
Response.Redirect ("http://" &
myselect.items(myselect.SelectedIndex).Value)
end if
End Sub

</script>

I looked in the .net and tryied several options but until now i wasn't able to make it work

This seems really simple. I don't know what is going on and i need to
deliver this as soon as possible. Can you help me?

Thank You,
Miguel


Nov 18 '05 #2
There was already a response in :

03/04/2004 -- Re: Jump Menu (DropDown Menu) in ASP.net. Can someone help
me out?
<script runat=server language=C#>
private void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{

}
}
private void DropDownList1_SelectedIndexChanged(object sender,
System.EventArgs e)
{
if (((DropDownList)sender).SelectedValue != "")
Response.Redirect(((DropDownList)sender).SelectedV alue);
}

</script>

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" OnLoad="Page_Load">
<asp:DropDownList id="DropDownList1" style="Z-INDEX: 101; LEFT: 184px;
POSITION: absolute; TOP: 184px"
runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged">
<asp:ListItem value="">select one...</asp:ListItem>
<asp:ListItem
value="http://www.bonsalunos.com">item1</asp:ListItem>
<asp:ListItem value="http://www.sapo.pt">item2</asp:ListItem>
<asp:ListItem value="http://www.google.com">item3</asp:ListItem>

</asp:DropDownList>
</form>
</body>

"Rajiv R" <ra********************@yahoo.com> wrote in message
news:e$**************@TK2MSFTNGP10.phx.gbl...
Hi Miguel,

Use the OnSelectedIndexChanged event of dropdownlist.
<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server"

OnSelectedIndexChanged="myselect_Change">
<asp:ListItem value="www.google.com">Google</asp:ListItem>
<asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
<asp:ListItem

value="www.macromedia.com">Macromedia</asp:ListItem>
</asp:DropDownList>


then you can write the handler as
void myselect_Change(Object sender, EventArgs e) {

}

--
Cheers!
Rajiv. R
Rajspace.Org

"Miguel Dias Moura" <in************@27lamps.com> wrote in message
news:#x**************@TK2MSFTNGP12.phx.gbl...
Hello,

I have a Drop Down List with 3 options. I want to redirect to a new page
when an options is selected. I don't want to use a button. The redirection should be fired when the option is selected.

I have an ASP.net / VB page with a Drop Down List named "my select" as
follows:

<asp:DropDownList AutoPostBack="true" ID="myselect" runat="server">
<asp:ListItem value="www.google.com">Google</asp:ListItem>
<asp:ListItem value="www.yahoo.com">Yahoo</asp:ListItem>
<asp:ListItem

value="www.macromedia.com">Macromedia</asp:ListItem>
</asp:DropDownList>

Then i have this script:

<script runat="server">

Sub Page_Load(Sender As Object, E As EventArgs)
if myselect.AutoPostBack then
Response.Redirect ("http://" &
myselect.items(myselect.SelectedIndex).Value)
end if
End Sub

</script>

I looked in the .net and tryied several options but until now i wasn't

able
to make it work

This seems really simple. I don't know what is going on and i need to
deliver this as soon as possible. Can you help me?

Thank You,
Miguel



Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
2
by: Miguel Dias Moura | last post by:
Hello, I have a Drop Down List with 3 options. I want to redirect to a new page when an options is selected. I don't want to use a button. The redirection should be fired when the option is...
13
by: Leszek Taratuta | last post by:
Hello, I have several drop-down lists on my ASP.NET page. I need to keep data sources of these lists in Session State. What would be the most effective method to serialize this kind of data...
0
by: JohnZing | last post by:
Hi, i have a list of drop down lists. The first one is populated with a Select Query The Second one is populated with a select query where ParentID is the first drop down list selected value...
6
by: Joey Liang via DotNetMonster.com | last post by:
Hi all, I have a drop down list which store all the different brands of product.When i selected the particular brand from the drop down list, it will display all the products with the selected...
7
by: Miguel Dias Moura | last post by:
Hello, i have an ASP.NET / VB page where i have a few 4 groups of Drop Down Lists. Each group of Drop Down Lists include 3 Drop Down Lists for date such as: DAY, MONTH, and YEAR. I don't want...
3
by: Mike Collins | last post by:
I'm not feeling too smart right now, but I cannot get the correct drop down list value from a drop down I have on my web form. I get the initial value that was loaded in the list. Can someone show...
2
by: newsgroups.jd | last post by:
Thanks for any advice, help in advance... I have 3 dropdownlist that populate based on choice in the previous (nested essentially) Problem is when I hit the back button and make a change in...
8
by: Ed Dror | last post by:
Hi there ASP.NET 2.0 VB & SQL Express Lest take Northwind Categories Products as example I create a table that hold these two together and I create a stored procedure like select ProductID,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.