OnClientClose client script not firing

5 posts, 0 answers
  1. Mark
    Mark avatar
    79 posts
    Member since:
    Apr 2007

    Posted 28 Oct 2009 Link to this post

    Need some help...

    Here's the js to open my rad window (working great)
    function GetRadWindow(){ 
       var oWindow = null
       if (window.radWindow) oWindow = window.radWindow; 
       else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
       return oWindow; 
     
    function OpenRadWindow(url, modal, width, height, name, cancelReturnValue, title, refresh, refreshElement, onClose) { 
        var oManager = GetRadWindowManager(); 
        if (oManager == null) { 
            alert("No Rad manager is available"); 
            return
        } 
        Wnd = oManager.open(url, name); 
        Wnd.setSize(width, height); 
        Wnd.set_title(title); 
        Wnd.setActive(true); 
        Wnd.SetModal(true); 
        Wnd.set_showContentDuringLoad(true); 
        Wnd.center(); 
        Wnd.refresh = refresh; 
        Wnd.cancelReturnValue = cancelReturnValue; 
        Wnd.returnValue = cancelReturnValue; 
        if (onClose!=null) Wnd.add_close(onClose); 
        if (refreshElement==null) refreshElement = "custom"
        Wnd.refreshElement = refreshElement; 

    Here's my code that SHOULD be firing when the window closes:

    <telerik:RadCodeBlock ID="cb1" runat="server"
        <script type="text/javascript"
            function refreshCustomFields(sender,eventArgs) 
            { 
              var ajaxManager = $find("<%= rapCustom.ClientID%>"); 
              ajaxManager.ajaxRequest(eventArgs); 
            } 
        </script> 
    </telerik:RadCodeBlock>  

    So, window opens great, when I close it, it should fire the "refreshCustomFields" JavaScript method which in turn will trigger an AjaxRequest on my RadAjaxPanel.  However, I get the following error in Firefox:

    Error: a[b] is not a function 
    Source File: http://localhost:64113/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_RadScriptManager1_HiddenField&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ad0c4ca6e-6b5d-49b6-922d-5244924fb100%3aea597d4b%3ab25378d2 
    Line: 6 

    And this error in IE 8 (Windows 7)
    Webpage error details 
     
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; OfficeLiveConnector.1.4; OfficeLivePatch.1.3) 
    Timestamp: Wed, 28 Oct 2009 21:14:42 UTC 
     
     
    Message: Function expected 
    Line: 6 
    Char: 29366 
    Code: 0 
    URI: http://localhost:64113/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl00_RadScriptManager1_HiddenField&compress=1&_TSM_CombinedScripts_=%3b%3bSystem.Web.Extensions%2c+Version%3d3.5.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d31bf3856ad364e35%3aen-US%3ad0c4ca6e-6b5d-49b6-922d-5244924fb100%3aea597d4b%3ab25378d2 

    The client script "refreshCustomFields" is in the source and the add_close(onClose) gets called and set properly when the window opens (JavaScript debugger).  But I get errors when I close the window.  Any help would be appreciated.



  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 02 Nov 2009 Link to this post

    Hi MJ,

    Your code looks fine. Have you checked if your refreshCustomFields() function is executed? What happens when you put a standard alert in it - does it fire at all?

    If you still experience problems, please open a support ticket and send us a small sample project where this issue could be reproduced. We will check it and do our best to help.


    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mark
    Mark avatar
    79 posts
    Member since:
    Apr 2007

    Posted 07 Nov 2009 Link to this post

    refreshCustomFields() doesn't fire at all.  I'll give it another go and open a support ticket if it still doesn't work.
  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 09 Nov 2009 Link to this post

    OK MJ,

    We'll be expecting your project - once we receive it, we will do our best to help.


    Kind regards,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Rob
    Rob avatar
    43 posts
    Member since:
    Aug 2010

    Posted 13 Feb 2012 Link to this post

    Did this ever get resolved?  I'm seeing the same issue when attempting to close a RadWindow.

    Rob

    --edit

    Never mind, found my problem - passing in the function name as a string instead of as a function.  For anyone that runs across similar issues, here's a utility function I wrote as I was researching the issue:

    function getFunctionFromName(fnName) {
        if (typeof fnName === 'function') return fnName;
        if (typeof fnName === 'string' && typeof window[fnName] === 'function') return window[fnName];
        return null;
    }

    It returns null if nothing is found, which of course is typeof object, because the rest of our window popup code is checking explicitly for null rather than checking for undefined.  You may want to adjust that bit for use elsewhere.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017