JavaScript not loaded for dynamically registrated scripts during async post back

Last post 03-10-2008 8:31 AM by vlesierse. 1 replies.

Sort Posts:

  • JavaScript not loaded for dynamically registrated scripts during async post back

    03-10-2008, 5:05 AM
    • Loading...
    • vlesierse
    • Joined on 06-14-2007, 4:28 PM
    • Posts 2

    Hi,

    Currenlty I have an application that is able to dynamically add (script)controls during async post back. With this I have some issues that I cannot solve.

    When the page starts for the first time the script of the control isn't loaded because it is simply not there yet. Then I perform an action on the page triggering a async post back. During this post back the (script)control will be added and its script is registrated with the ScriptManager. Somehow this script isn't returned to the client so it will not load the initial JavaScript cuases script errors and the application is useless. Only when I hit the refresh on the browser (and this time the controls is on the page for the first) it works.

    Is there a solution for this problem?

     Thnx

  • Re: JavaScript not loaded for dynamically registrated scripts during async post back

    03-10-2008, 8:31 AM
    Answer
    • Loading...
    • vlesierse
    • Joined on 06-14-2007, 4:28 PM
    • Posts 2

    I have found a solution that works for me, but I wonder if there isn't an alternative. Now I use the Control State to keep track of the registrated JavaScript Url's. If a registered URL (ScriptManager.GetRegistratedClientScriptBlocks) doesn't match with the collection of Url's in the from the Control State it will register the script (ScriptManager.RegisterClientScriptInclude) on page level. This forces the JavaScript to load on the client.

Page 1 of 1 (2 items)
Microsoft Communities
Page view counter