Wednesday, March 21, 2012

Question for custom controls builder

Hi,

I build a common (non AJAX) custom control.

My control renderJavaScript with thePage.ClientScript.RegisterClientScriptResource method, so it do not work when inside an UpdatePanel.

How can we detect if the control is placed inside an UpdatePanel and use the correct method to render JavaScript ?

I found a very interesting article but it seems that it do not work with AJAX RTM bits :
http://weblogs.asp.net/leftslipper/archive/2006/11/13/HOWTO_3A00_-Write-controls-compatible-with-UpdatePanel-without-linking-to-the-ASP.NET-AJAX-DLL.aspx

How do you deal with that problem ?

The best way (I think) would be to have it happen at the server level by iterating over the control hierarchy (looking at its ancestor containers) until it gets to Page to see if any of them are of type UpdatePanel.

No comments:

Post a Comment