473,503 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1561
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
2543
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
303
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
5210
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
901
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
2019
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
6301
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
12472
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
1454
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
7561
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
7287
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
7353
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...
1
7011
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
7468
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
5596
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,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4689
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.