Radwindow doesn't Hide When Press a Esc Key

6 posts, 0 answers
  1. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 14 Feb 2011 Link to this post

    I am using RadWindow in my web application but when I press a escape key radwindow doesn't hide, when I checked the code of GetRadWindow() I found out that I am getting undefined object in my radwindow. I have also tried to hide my radwindow by using telerik shorcuts but the problem is that once it hides it never comes back again. I am showing my radwindow when user press a link button in my page. I don't understand that why I am getting undefined in my GetRadWindow() function. Any help would be greatly appreciated.

    function closeWindow() {
                var oWnd = GetRadWindow();            

     function GetRadWindow()
      var oWindow = null;
    if (window.rwCustomerListDialog)
     = window.rwCustomerListDialog;
    else if (window.frameElement.rwCustomerListDialog)
     = window.frameElement.rwCustomerListDialog;
    return oWindow;

            function pageLoad() {

                $addHandler(document, 'keydown', onKeypress);

            function onKeypress(args) {

                if (args.keyCode == Sys.UI.Key.esc) {


    <telerik:RadWindow ID="rwCustomerListDialog" runat="server" Title="Add Customer"
                    VisibleStatusbar="false" Behaviors="Move,Pin,Resize" InitialBehaviors="Pin" VisibleOnPageLoad="true"
                    Visible="false" OffsetElementID="rwCustomerListDialog" Height="500" Width="510"
                    Left="150px" KeepInScreenBounds="true" DestroyOnClose="true">
     <table id="tblAddCustomer" border="0" cellpadding="0" cellspacing="0" width="100%"
                                <td width="26%" align="right">
                                    <asp:Label ID="Label2" runat="server" Text="Customer code" Font-Bold="true" />
                                    <asp:TextBox ID="tbCustomerCode" runat="server" Width="200px" />
                                    &nbsp;<asp:RequiredFieldValidator ID="rfvCustomerCode" runat="server" ErrorMessage="required!"
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 14 Feb 2011 Link to this post

    Hello Jo,

    Access the RadWindow client object using $find() method instead of using GetRadWindow() and see whether that helps.

    Client code:
    function closeWindow() {
        var wnd = $find('<%= rwCustomerListDialog.ClientID %>');

  3. Muhammad
    Muhammad avatar
    87 posts
    Member since:
    Oct 2012

    Posted 14 Feb 2011 Link to this post

    Yes, that's work perfectly. Thank u.
  4. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 16 Feb 2011 Link to this post

    Hi Muhammad,

     I also suggest to examine the following online demo about the recently added keyboard support:


    Adding a shortcut for Esc key to close the RadWindow is as easy as setting a property instead of adding custom code.

    All the best,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Billy
    Billy avatar
    18 posts
    Member since:
    May 2006

    Posted 06 Mar 2012 Link to this post

    If you click a link in one of the windows for the demo the shortcut keys no longer work. Is this by design? Is there a way around this? I would like to use the "Esc" key to close the rad window however if the user does anything within the window it no longer works.

  6. Marin Bratanov
    Marin Bratanov avatar
    5922 posts

    Posted 07 Mar 2012 Link to this post

    Hello Billy,

    When you load an external page in the RadWindow it is actually loaded in an iframe. This means that it creates its own document and window objects, so events inside cannot bubble to the main page. This is why once the focus is set in the content page (i.e. you clicked a link) the parent page no longer knows what you do, so it cannot react. There is no way around this, because we cannot attach handlers to external pages. What you can do is add a onkeypress handler to your own content pages (in the case you can control this and they come from the same domain as the main page) and check for the Esc key. If it is pressed you can get a reference to the RadWindow an call its close() method from inside the content page.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top