Reset the controls within asp placeholder

Posted by alaa9jo on ASP.net Weblogs See other posts from ASP.net Weblogs or by alaa9jo
Published on Sun, 02 May 2010 14:27:00 GMT Indexed on 2010/05/03 8:38 UTC
Read the original article Hit count: 499

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.

© ASP.net Weblogs or respective owner

Related posts about AJAX

Related posts about ASP.NET