views:

51

answers:

1

I have a page that contains a custom tab control. When you click different tabs, it does a an ajax callback. During that ajax call, the code dynamically loads a different control based on which tab was clicked, then adds it to the appropriate tab. So basically I have some code that does a switch statement, uses LoadControl(), then adds the control in.

The issue I'm having is that none of the javascript within each of those controls that gets loaded is getting registered on the page. Based on this thread:

http://stackoverflow.com/questions/297081/registerclientscriptblock-within-ajax-method-call

I thought I just had to switch from using Page.ClientScript.RegisterClientScriptBlock to ScriptManager.RegisterClientScriptBlock. I did that, but still nothing. Am I misunderstanding something about the ScriptManager? I want the javascript to be registered from within the dynamically loaded control, which happens to be loaded during an AJAX call.

Thanks in advance.

A: 

I had the same issue when loading web controls within an UpdatePanel. The problem is that the JavaScript code that is dynamically loaded into the page is not automatically parsed.

I have solved it from the information in this article

Just reuse the InlineScript control that is provided and wrap it around your <script /> tags. It will do the rest for you.

Xavier Poinas