Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
| Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
  #1 (permalink)  
Old February 3rd, 2006, 03:54 PM
Authorized User
 
Join Date: Feb 2006
Location: Charlotte, NC, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectedIndexChanged Event doesn't fire

Hello.
I have an ASP.NET Website with several Web pages written in C#
with the WebControls.Menu object at the top of each page.

I have a DropDownlist on one of the 1st web pages that has a SAVE button at the bottom.

I had a request to change the menu on the pages to have a BACK button so if they wanted to go back to the previous web page they can.

I'm holding off the value selected in the DropDownlist in a Session variable so I can use it when moving through these web pages to pull up only the data I need.

When this BACK button is selected I'm checking the Session variable in the PAGE_LOAD to see if it has a value in it and then selecting the DropDown List's item (which works) by setting the SelectedIndex property, but the SelectedIndex_Changed event is not firing when I set it manually and subsequently not loading the rest of the web page with my dataset.

Can anyone tell me why? or have a way I can make this work?

Thanks,
David
__________________
Thanks,
David
  #2 (permalink)  
Old February 3rd, 2006, 04:17 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Changing the value of the ddl in code will not fire the event.

If you click the back button, the values should remain the same because of viewstate. Unless you are setting values in code in the Page_Load event for example.

  #3 (permalink)  
Old February 3rd, 2006, 04:27 PM
Authorized User
 
Join Date: Feb 2006
Location: Charlotte, NC, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

--If you click the back button, the values should remain the same
--because of viewstate. Unless you are setting values in code in
--the Page_Load event for example.


I am setting values based on !Page.IsPostBack and at the point the page is loaded again from the back button IsPostBack is false. So I'm reloading everything because of that. Is there a way to check the VIEWSTATE to know that I have values from the previous time the page was loaded and load those values instead?

Thanks,
David
  #4 (permalink)  
Old February 3rd, 2006, 04:56 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

I'm not sure I understand. If you click the back button, the page is not posted back, it just shows a cached version of the page, so, your IF !Page.IsPostBack will not be evalutated, and nothing should reset.

  #5 (permalink)  
Old February 3rd, 2006, 05:05 PM
Authorized User
 
Join Date: Feb 2006
Location: Charlotte, NC, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The Menu Control simply has a NavigateURL set to the previous page.

All I can say is it sure is hitting the Page_load procedure and the IsPostBack is false when I "press" the BACK option. I have a breakpoint on it and it's hitting it.

fYI I'm clearing the page on IsPostback == false and disabling controls so it starts over fresh. So am I doing something incorrectly as far as navigation is concerned? or is this a bug?




Thanks,
David
  #6 (permalink)  
Old February 3rd, 2006, 05:31 PM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

   Ok, I see now. I was using the browser's back button while testing, not a hyperlink. So, you page will reload as you have said.
   You can manually call the selectedindex changed event, but I wouldn't recommend that. What I would do, is take your code in that event and place it in a sub on the page or in a class. Then when you check the session variable if it exists, set the value in the ddl as you do AND call this new sub with the code in it.

Jim

  #7 (permalink)  
Old February 6th, 2006, 09:22 AM
Authorized User
 
Join Date: Feb 2006
Location: Charlotte, NC, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks. This seems to work great!

David

Thanks,
David
  #8 (permalink)  
Old February 6th, 2006, 10:47 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

Glad you got it working..



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
DropDownList SelectedIndexChanged Event does not davej ASP.NET 2.0 Basics 3 October 12th, 2007 10:20 AM
GridView SelectedIndexChanged event bnorg ASP.NET 2.0 Professional 1 July 7th, 2007 01:14 AM
SelectedIndexChanged wont fire in content page alemadlei ASP.NET 2.0 Basics 1 May 28th, 2006 11:00 AM
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.