Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 6th, 2004, 06:18 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Listbox selectedindexchanged event

I have a listbox and a dropdownlist on a asp.net web form.
when the user selects an item in the listbox, it goes to another page, which is fine.
If you go back to the page with the listbox and select an item from the dropdownlist, the listbox selectedindexchanged event is fired instead of the dropdownlist selectedindexchanged event.

What can i do to prevent this?
 
Old December 7th, 2004, 06:03 PM
Authorized User
 
Join Date: Sep 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When you say "go back," are you using the browser's back button?
If not you may want to set the SelectedIndex back to 0 in the page_load. Or you could test if the dropdownlist SelectedIndex has changed in the listbox SelectedIndexChanged event. It sounds like the listbox event is firing because it come first on the page.

-Hunter
 
Old December 8th, 2004, 08:03 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, if i use the browser's back button.
Is there a way to set the listbox.selctedindex to -1 if you use the browser's back button.

 
Old December 8th, 2004, 08:09 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Or is there a way to prevent the listbox to fire before the dropdownlist

 
Old December 8th, 2004, 09:08 AM
Authorized User
 
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can you show us your codes?

 
Old December 8th, 2004, 01:15 PM
Authorized User
 
Join Date: Sep 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe a moderator will correct me if I'm wrong, but I'm fairly sure there is nothing you can do to the page when you use the back button. The browser doesn't reload the page when you press back, it just recalls it from the cache.
Its always best to try to avoid use of the back button with forms. Are you linking to your own pages? You could provide a link to navigate back to the page with the listbox and dropdownlist.

-Hunter
 
Old December 9th, 2004, 08:46 AM
Authorized User
 
Join Date: Dec 2004
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

the actual problem is when an item is selected in the listbox, the listbox selectedindexchanged evnet fires when i clicked on the dropdownlist, i want the dropdownlist selectedindexchanged event to fire.

I know it is because an item in the listbox is selected, but how can i ignore the selected item in the listbox and fire the the selectedindexchanged event of the dropdownlist instead






Similar Threads
Thread Thread Starter Forum Replies Last Post
help related to a SelectedIndexChanged event suneet.pant ASP.NET 2.0 Professional 1 May 22nd, 2008 04:41 PM
ListBox.SelectedIndexChanged not fired (composite) studen77 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 March 27th, 2007 08:40 PM
SelectedIndexChanged Event doesn't fire ddudley3 ASP.NET 2.0 Professional 7 February 6th, 2006 10:47 AM
adding SelectedIndexChanged event to listbox msrnivas General .NET 1 July 19th, 2005 02:47 PM
listbox event SelectedIndexChanged alyeng2000 ASP.NET 1.0 and 1.1 Basics 2 December 22nd, 2003 10:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.