- Give your server side form tag some ID, mine is aspnetForm
- In the thickbox.js, modify every code that adds or remove stuff from the body, to #aspnetForm instead.
04Aug
ASP.NET UserControl inside Thickbox
I love the Thickbox. It's fast, easy to use and I've not had any problems with it, until today.
I added an ASP.NET UserControl to a page. This user control was a form where readers should be able to submit comments. Additional to scrolling down to the bottom of the page, I wanted to make the form available in a thickbox. However, as soon as my form was in the whitebox window it stopped responding to ASP.NET events, such as button click.
The reason for this was simple. When the thickbox window opens it will copy the content to a new node called TB_window under the body. This won't work with ASP.NET UserControls because they have to stay inside the server form tag. Otherwise, events will not be triggered. Since I did not want to load my user control inside an IFrame, I opened up the thickbox.js and did some modifications.

7 Comments
wu said
thank you for the problem.
but,do you know how to keep the window in model state after some control postback?
Mikael Lundin said
@Eric I would not suggest you do postback inside the thickbox itself. If you want to remain within the thickbox after submitting some form I would suggest that you do the form posting by AJAX. Maybe if your thickbox where an IFrame you could get away with a postback and stay on the same page. Have you tried that?
Eric said
Thank you for this! It seems to be very close. However when I submit the form inside the Thickbox and the page Posts back the thickbox contents open in a new window. How can I keep the contents in a thickbox?
Mikael Lundin said
Try to look for what POST variables was sent on postback by putting a debug break in Page_Load and a watch on the Request instance. If it's working properly you should have your asp.net controls posted their values as POST variables.
James said
Thanks for posting this solution however I cannot get it work just yet.
I have set the form id to aspnetForm along with your thickbox.js but the code behind for any server controls does not work.
Am I missing something?
Praveen said
Hi
"Thickbox in Datalist paging control" is not working after click on next page of datalist.
Please help me.
Thank you,
Praveen
jwaite said
This was very helplful for me. Thank you!