Search code examples
javascripttelerikradwindow

How to close a RadWindow not usting the default "X"?


I have a RadWindow as following:

<telerik:RadWindow ID="PIQRadWindow" Modal="true" runat="server" Skin="Default" Behaviors="Close,Move" CssClass="RadWindowCustomClass" VisibleStatusbar="false" width="400px" OnClientClose="RadWindowClose">
    <ContentTemplate>
    <pd:uc_PopupDropdown ID="pdPIQScore" enableviewstate="False" Draggable="true" isInternal="true" ISOC="ProjectInstructionQuality" DivContent = "pdPIQScore" ScriptPrefix = "OFS_" runat="server" />  
    </ContentTemplate>     
    </telerik:RadWindow>

I want it to be closed within a onclick event I defined. I tried to use

   function getRadWindow() {
      var oWindow = null;
      if (window.radWindow) oWindow = window.radWindow;
      else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
      return oWindow;
   }

   function clientClose() {   
      getRadWindow().close();
   }

But it's not working for me. Error message: "window.frameElement is null".

Anyone has ideas?


Solution

  • You must use $find() when using the ContentTemplate. You can either keep a reference in a global JS variable (you can populate the variable in Sys.Application.Load), or create functions that will open and close the dialog and call them whenever needed. Check this demo's code: http://demos.telerik.com/aspnet-ajax/window/examples/contenttemplatevsnavigateurl/defaultcs.aspx.