This is a migrated thread and some comments may be shown as answers.

RadWindow Close with Esc Key

10 Answers 669 Views
Window
This is a migrated thread and some comments may be shown as answers.
Ravi Gorrepati
Top achievements
Rank 1
Ravi Gorrepati asked on 22 Aug 2008, 10:32 AM
Hi, help me
i am using teleric radwindow as a modal popup.
My requirement is Radwindow should close when the user press ESC key from keyboard. radwindow does not have any close() method.  what cod ei have to write.

10 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 22 Aug 2008, 11:28 AM
Hi Ravi,

If RadWindow is not modal (e.g. Modal=true), it will be closed if the user presses the Esc key - you can check this on our online demo (note that the RadWindow must be focused for Esc to work - e.g. you need to click on the RadWindow's titlebar if the focus is somewhere else).

If you wish to close RadWindow by code, RadWindow has a close() method. More information on it and its usage is available in the documentation.


Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ravi Gorrepati
Top achievements
Rank 1
answered on 22 Aug 2008, 11:59 AM
Hi,

Thanks for u r reply.
but i am using Radwindow as Modal. (Modal=true),
in this case how to close it with ECS key press.
0
Georgi Tunev
Telerik team
answered on 25 Aug 2008, 11:27 AM
Hello Ravi,

In such case you will need to capture the Esc key and if it is pressed and there is a RadWindow active on the page, you can get a reference to it and call its close() method.

Since this task is not directly related to RadWindow but is a general one, my suggestion is to implement your logic by using window.open() - e.g. standard browser's popup. Once you have your code working as expected, the same logic will work with RadWindow as well.




Best wishes,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Justyn
Top achievements
Rank 1
answered on 02 Nov 2010, 06:00 PM
Here is a Link to the demo for those who found this through searching.
0
Georgi Tunev
Telerik team
answered on 03 Nov 2010, 03:21 PM
Hi Justyn,

Yes, this is a new functionality that was recently added to the RadWindow features list.

Best wishes,
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
0
Dinesh
Top achievements
Rank 1
answered on 06 Jan 2016, 01:05 PM
RadWindow1.Shortcuts.Add("Close", "Esc");
or
RadWindow1.Shortcuts.Add(new Telerik.Web.UI.WindowShortcut("Close", "Esc");
0
hassan
Top achievements
Rank 1
answered on 13 Aug 2019, 10:31 AM

I have just use this  method:

RadWindow1.Shortcuts.Add("Close", "Esc");

and it is working.

but I have another contorl on page like that:

<asp:Button ID="btnRefresh" runat="server" UseSubmitBehavior="false"   OnClientClick="disableBtn(this.id)" />

for refreshing the page after the window closed, but the button still been disabled after closing the rad window with 'Esc', but the button work well when closed the window with clicking the close button 'X' on title bar!

0
Rumen
Telerik team
answered on 13 Aug 2019, 11:54 AM
Hello,

I performed a simple test with the following configuration:

<script>
    function OnClientClose() {
        alert(1);
    }
</script>
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientClose="OnClientClose">
    <ContentTemplate>AAA</ContentTemplate>
</telerik:RadWindow>

Codebehind
protected void Page_Load(object sender, EventArgs e)
{
    RadWindow1.Shortcuts.Add("Close", "Esc");
}

and version 2019.2.514 of the control.

What I noticed that the OnClientClose client event of RadWindow gets executed when pressing Esc in all browsers.

Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
hassan
Top achievements
Rank 1
answered on 14 Aug 2019, 05:02 AM
Thank you for your reply, yes your are right, the onclientclose function call correctly, so close window run correctly, but I think something went wrong with UseSubmitBehavior="false" for button and postback not happened, because I call button click in javascript, on radwindow onclientclose()
0
Rumen
Telerik team
answered on 14 Aug 2019, 05:13 AM
With the following code I managed to disable the button on the client after hitting the escape key:

<script>
    function OnClientClose() {
        $get("btnRefresh").click();
    }
 
    function disableBtn(id) {
        $get(id).disabled = true;
        return false;
    }
</script>
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true" OnClientClose="OnClientClose">
    <ContentTemplate>AAA</ContentTemplate>
</telerik:RadWindow>
 
<asp:Button ID="btnRefresh" runat="server" Text="Refresh Button" UseSubmitBehavior="false" OnClientClick="disableBtn(this.id); return false" />


Regards,
Rumen
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
Ravi Gorrepati
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Ravi Gorrepati
Top achievements
Rank 1
Justyn
Top achievements
Rank 1
Dinesh
Top achievements
Rank 1
hassan
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or