AJAX.NET Partial Refresh SOLUTION

  •  07-08-2007, 5:19 AM

    AJAX.NET Partial Refresh SOLUTION

    Hi Adam,
     
    I think I have found an issue with the way CE registers it's scripts on an AJAX enabled page.
     
    If you create a page, place CE in an update panel and set CE property visible=false. Now add a button which changes the visiblity of CE to true, and add it as a trigger the the update panel. You'll notice that CE fails to load correctly when the page is updated.
     
    I have identified that the problem is that your scripts are loaded similar to the following:
     
    <script src="http://cutesoft.net/CuteSoft_Client/CuteEditor/Load.ashx?type=scripts&amp;file=IE_Loader"></script>
    <img src="http://cutesoft.net/CuteSoft_Client/CuteEditor/images/1x1.gif?xxxxx" onload="CuteEditorInitialize(...)" />
     
    The issue is that the script tag will not be loaded if it is contained in a partial page refresh. Your AJAX example works because CE is visible when the page first loads.
     
    Microsoft provide a means to load scripts through the ScriptManager object. If you use the following code to register the script then the script will load correctly on a partial refresh.
     
    ScriptManager.RegisterClientScriptInclude(Me, Me.GetType(), "LABEL", "JS PATH")
    ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "initialisation", "CuteEditorInitialize(...);", True)
     
    You will also have to add the following call-back to the end of the JS file:
     
    if (typeof(Sys) !== 'undefined') {
      Sys.Application.notifyScriptLoaded();
    }
     
    I notice that in other topics in this forum your answer is usually to set the EnablePartialRendering property of ScriptManager to false, which kind of defeats the point of using AJAX. I thought I'd point out the root cause of these problems and a solution (just to be nice).
     
    Thanks,
    Ady
     
View Complete Thread