DestroyOnClose not working with client-side close

4 posts, 0 answers
  1. Craig Wallace
    Craig Wallace avatar
    117 posts
    Member since:
    Jan 2005

    Posted 10 Aug 2010 Link to this post

    Hi,

    I am using client script to close my RadWindow after postback, as follows:

    <telerik:RadWindowManager ID="rwmWindow" Width="500px" Height="375px" 
        runat="server" DestroyOnClose="true" Modal="true" VisibleOnPageLoad="false" 
        Title="New Rad Window">
        <Windows>
            <telerik:RadWindow ID="rwWindow" runat="server" ReloadOnShow="true" ShowContentDuringLoad="false" DestroyOnClose="true" Behaviors="Close,Resize,Move" OpenerElementID='<%# Parent.FindControl("btnMyLaunchButton").ClientID %>'>
                <ContentTemplate>
                <script language ="javascript" type ="text/javascript" >
                    function GetRadWindow() {
                        var oWindow = null;
                        if (window.radWindow)
                            oWindow = window.RadWindow; //Will work in Moz in all cases, including clasic dialog       
                        else if (window.frameElement.radWindow)
                            oWindow = window.frameElement.radWindow; //IE (and Moz as well)       
                        return oWindow;
                    }
      
                    function Close() {
                        GetRadWindow().Close();
                    }           
                    </script
    <div class="window">
    <p>This is the new rad window</p>
                    <asp:literal ID="litClose" runat="server" Visible="false"></asp:literal>
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="Submit_Click"/>
                    </div>
                </ContentTemplate>
        </telerik:RadWindow>        
        </Windows>
    </telerik:RadWindowManager>

    Now within Submit_Click I update the literal as follows:

    litClose.Text =

     

    "<script type='text/javascript'>Close()</" + "script>";

     

     


    This works fine, but the DestroyOnClose attribute of the window seems to be ignored as when I next launch the window, the contents are still there.

    How can I destroy the window using the client-side close?

    Thanks.

  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts
    Member since:
    Sep 2012

    Posted 13 Aug 2010 Link to this post

    Hello Craig Wallace,

    Please, note that  it is not valid to use the DestroyOnClose property with value true when the content is on the same page because this will destroy the inner controls and you should recreate them. To clear the content in the controls with ViewState inside the RadWindow, you can directly assign empty or default value either in the OnClientClose event on the client or on the server, depending on your logic. Referencing the controls can be done directly because they reside on teh same page which is much easier than referencing them when they are in an external page loaded in the RadWindow.

    Sincerely yours,
    Svetlina
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

  3. DevCraft Release
  4. Craig Wallace
    Craig Wallace avatar
    117 posts
    Member since:
    Jan 2005

    Posted 13 Aug 2010 Link to this post

    Hi Svetlina,

    Can you give me an example of how I can call server-side code with OnClientClose?  Or an example of client-side code?

    I have tried this:

    function ClientClose(sender, eventArgs) {
       $find("<%= txtNumber.ClientID %>").Value = "";
       $find("<%= txtCustomerName.ClientID %>").Value = "";
       var calendar = $find("<%= txtCallbackDate.ClientID %>");
       var dates = calendar.get_selectedDates();
       calendar.unselectDates(dates);
       $find("<%= dlCallbackType.ClientID %>").Value = "";
       $find("<%= txtCallbackNotes.ClientID %>").Value = "";
    }

    but nothing happens, and I don't get reliable exception handling either.

    Craig

  5. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7206 posts
    Member since:
    Sep 2012

    Posted 18 Aug 2010 Link to this post

    Hi Craig Wallace,

    To call a server-side function from JavaScript, you can manually call __doPostBack() or RadAjax's ajaxRequest.

    A sample showing the last approach is available in the Edit Dialog for RadGrid demo where the refreshGrid() function makes an ajax call to rebind the grid on the server.


    All the best,
    Georgi Tunev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Back to Top