SteveOH

ThickBox 3.1 within ASP.NET UpdatePanel

by Steve Hernandez on Jun.28, 2008, under Technology

So, out of the box, this just doesn’t work.  Here’s the situation.

Thickbox works fine before any async postbacks by the updatepanel.  However, once the updatepanel is reloaded (does a postback), thickbox will no longer work and will render your links regular HTML links.

The Reason

The reason for this is when the updatepanel posts back, the javascript is reloaded but is not initialized, nor is it registered with the DCOM.

Solution

Add the following code to the pageLoad method in your AJAX enabled page, so that it looks something like this:

<script type=”text/javascript” language=”javascript”>
function pageLoad()
{
var isAsyncPostback = Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack();
if (isAsyncPostback) {
tb_init(‘a.thickbox, area.thickbox, input.thickbox’);
}
}
</script>

This code will check if there is an async post back being fired, and if so, will re-initialize thickbox.

I search around for at least 4 hours until I was able to piece together some solutions.  This is the best one.

Good luck.

ASP.NET UpdatePanel ATLAS AJAX ThickBox modal iframe

:, ,

27 Comments for this entry

3 Trackbacks / Pingbacks for this entry

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...