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

February 3rd, 2006, 03:54 PM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

February 3rd, 2006, 04:17 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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.
|

February 3rd, 2006, 04:27 PM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
--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
|

February 3rd, 2006, 04:56 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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.
|

February 3rd, 2006, 05:05 PM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

February 3rd, 2006, 05:31 PM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
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
|

February 6th, 2006, 09:22 AM
|
Authorized User
|
|
Join Date: Feb 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks. This seems to work great!
David
Thanks,
David
|

February 6th, 2006, 10:47 AM
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Glad you got it working..
|
|
 |