Right, bit of a pickle here! Basically, I have a page which users flick through jobs to ensure everything ok. They put some criteria in (which filters the jobs) and some business logic throws out the next job id. I put this into viewstate (so the business logic isn't called on ajax postbacks) and populate the page - all good!
The problem: a job can have a range of sub tasks, the number and type of which, are random. Based on the task type I load a different user control to display the task information. These are, therefore, loaded in dynamically when they request a job. The controls perform ajax requests themselves, so this needs to be repopulated and events correctly hooked up.
This is the problem...
1) I need the JobId (from the page, stored in view state) to work out which controls I need to re-add dynamically, so the controls need to be added after viewstate is available (onload).
2) I need to add the controls before the viewstate is available, so that the values are extracted from the viewstate correctly and auto-populated by the framework (in preint just like MS recommend).
So I'm in a chicken and egg situation; If I add the controls on preinit, the jobid cannot be found as the viewstate hasn't been extracted yet.
Just wondering what best practice is? I could have a dictionary<int,int> in session or cache to find out the last jobid for a given user, but it all seems a bit megh? Is there a way after the page / controls viewstate has been extracted / repopulated to refire that action for certain controls? The IDs are set programmatically, so the values can be linked up.
Any help / best practice advice would be appreciated!
The problem: a job can have a range of sub tasks, the number and type of which, are random. Based on the task type I load a different user control to display the task information. These are, therefore, loaded in dynamically when they request a job. The controls perform ajax requests themselves, so this needs to be repopulated and events correctly hooked up.
This is the problem...
1) I need the JobId (from the page, stored in view state) to work out which controls I need to re-add dynamically, so the controls need to be added after viewstate is available (onload).
2) I need to add the controls before the viewstate is available, so that the values are extracted from the viewstate correctly and auto-populated by the framework (in preint just like MS recommend).
So I'm in a chicken and egg situation; If I add the controls on preinit, the jobid cannot be found as the viewstate hasn't been extracted yet.
Just wondering what best practice is? I could have a dictionary<int,int> in session or cache to find out the last jobid for a given user, but it all seems a bit megh? Is there a way after the page / controls viewstate has been extracted / repopulated to refire that action for certain controls? The IDs are set programmatically, so the values can be linked up.
Any help / best practice advice would be appreciated!