Reset the controls within asp placeholder
- by alaa9jo
I use placeholders very much in many projects,but in one of the projects I was asked to reset the controls within a specific placeholder to their original state after the user has finished from inserting his/her data.
As everyone of us know,to keep the controls within a placeholder from disappearing after postbacks you have to recreate them,we add such a code in i.e. page_load,the controls will be recreated and their values will be loaded from viewstate (for some of them like textbox,checkboxs,..etc) automatically,that placeholder contains only textboxs so what I need is to block/ loading/clear that viewstate after inserting the data.
First thought: Customizing placeholder
I thought about it and tried overriding many methods but no success at all...maybe I'm missing something not sure.
Second thought: recreate the controls 2 times:
In page_load,I recreate the controls within that placeholder then in button click (the button that saves user's data) I recreate them once more and it worked!
I just thought of sharing my experience in that case with everyone in case anyone needed it,any better suggestion(s) is welcomed.