Standard pattern for updating a tab in one click?
-
OK, I'm fairly green with ASP.net and I keep running into the same problem and I've solved it in various ways but none to my satisfaction. What I want: - To be able to click on a button/link or choose an option from a dropdownlist and have a tab be updated immediately with data supplied by the event set off by the button/link/dropdown. What I can do so far: - First click updates the tab and *then* sets the necessary variables that my tab needs to update properly. A second click re-updates the tab correctly. So, I use the OnClick event (or similar) of the button to set Session variables (values of which may come from a db) that the tab's OnLoad event needs to load itself properly. Unfortunately, the OnLoad of the tab happens before the OnClick of the button. Question: - What is the standard, non-javascript, way of making a C# function happen before the button engages the OnLoad event? Preferably I'd like the OnLoad to only happen once, but if the only way is for the thing to be set off twice, I can live with that. :)
Alex
-
OK, I'm fairly green with ASP.net and I keep running into the same problem and I've solved it in various ways but none to my satisfaction. What I want: - To be able to click on a button/link or choose an option from a dropdownlist and have a tab be updated immediately with data supplied by the event set off by the button/link/dropdown. What I can do so far: - First click updates the tab and *then* sets the necessary variables that my tab needs to update properly. A second click re-updates the tab correctly. So, I use the OnClick event (or similar) of the button to set Session variables (values of which may come from a db) that the tab's OnLoad event needs to load itself properly. Unfortunately, the OnLoad of the tab happens before the OnClick of the button. Question: - What is the standard, non-javascript, way of making a C# function happen before the button engages the OnLoad event? Preferably I'd like the OnLoad to only happen once, but if the only way is for the thing to be set off twice, I can live with that. :)
Alex
-
google ASP.NET page life cycle. The on load event will ALWAYS occur before the On click event. Once you understand the cycle better it will help you rearrange your code to fit it to get the desired results
That's my question: How *do* I rearrange my code to fit the desired result? Or, is there some AJAXy thing I can do to the button that will allow code to run first and then load a control? (I should have mentioned that I have looked at the page lifecycle and I still have no idea how to accomplish what I need. My workaround so far has been requiring a selection of an item (datagrid selection, dropdown selection, etc.) and then a button click to confirm the selection.)
Alex
-
That's my question: How *do* I rearrange my code to fit the desired result? Or, is there some AJAXy thing I can do to the button that will allow code to run first and then load a control? (I should have mentioned that I have looked at the page lifecycle and I still have no idea how to accomplish what I need. My workaround so far has been requiring a selection of an item (datagrid selection, dropdown selection, etc.) and then a button click to confirm the selection.)
Alex
You had not indicated it was in a ajax call. Typically when an item is not updated in a ajax call even though you attempt to on the server side, the item that does not update isn't in the ajax container that is being updated and therefore doesn't change on the client but the server thinks it has still. A 2nd postback reveals the change. edit for typo
modified on Wednesday, March 25, 2009 8:58 AM
-
You had not indicated it was in a ajax call. Typically when an item is not updated in a ajax call even though you attempt to on the server side, the item that does not update isn't in the ajax container that is being updated and therefore doesn't change on the client but the server thinks it has still. A 2nd postback reveals the change. edit for typo
modified on Wednesday, March 25, 2009 8:58 AM
Well, in this case, the problem is that I click the button and... 1. The tab, I want updated, gets updated with old information thanks to obsolete session variables and whatnot. 2. The C# code executes - changing the session variables to the values I need (the values being decided by which GridView row the user selected and/or by querying the db). Result: A tab with old information. What would I need to do to recover the correct values I need and then update the tab with one click/selection?
Alex
-
Well, in this case, the problem is that I click the button and... 1. The tab, I want updated, gets updated with old information thanks to obsolete session variables and whatnot. 2. The C# code executes - changing the session variables to the values I need (the values being decided by which GridView row the user selected and/or by querying the db). Result: A tab with old information. What would I need to do to recover the correct values I need and then update the tab with one click/selection?
Alex
make sure the tab is part of the ajax update. Make the changes in the onclick event. Is the tab in a update panel that is updated by the button? If not your changes will not be visible until another postback occurs. On sucessful execution of a ajax call, only items in the panel for that update change on the client. The server side viewstate however is updated with all changes. When a 2nd post back occurs, the changes from the viewstate end up showing on the client. I don't know how to be more specific.
-
make sure the tab is part of the ajax update. Make the changes in the onclick event. Is the tab in a update panel that is updated by the button? If not your changes will not be visible until another postback occurs. On sucessful execution of a ajax call, only items in the panel for that update change on the client. The server side viewstate however is updated with all changes. When a 2nd post back occurs, the changes from the viewstate end up showing on the client. I don't know how to be more specific.