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();
oWnd.hide();
}
function GetRadWindow()
{
var oWindow = null;
if (window.rwCustomerListDialog)
oWindow = window.rwCustomerListDialog;
else if (window.frameElement.rwCustomerListDialog)
oWindow = window.frameElement.rwCustomerListDialog;
return oWindow;
}
function pageLoad() {
$addHandler(document, 'keydown', onKeypress);
}
function onKeypress(args) {
if (args.keyCode == Sys.UI.Key.esc) {
closeWindow()
}
}
<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">
<ContentTemplate>
<table id="tblAddCustomer" border="0" cellpadding="0" cellspacing="0" width="100%"
runat="server">
<tr>
<td width="26%" align="right">
<asp:Label ID="Label2" runat="server" Text="Customer code" Font-Bold="true" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="tbCustomerCode" runat="server" Width="200px" />
<asp:RequiredFieldValidator ID="rfvCustomerCode" runat="server" ErrorMessage="required!"
ControlToValidate="tbCustomerCode"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</ContentTemplate>
</telerik:RadWindow>
function closeWindow() {
var oWnd = GetRadWindow();
oWnd.hide();
}
function GetRadWindow()
{
var oWindow = null;
if (window.rwCustomerListDialog)
oWindow = window.rwCustomerListDialog;
else if (window.frameElement.rwCustomerListDialog)
oWindow = window.frameElement.rwCustomerListDialog;
return oWindow;
}
function pageLoad() {
$addHandler(document, 'keydown', onKeypress);
}
function onKeypress(args) {
if (args.keyCode == Sys.UI.Key.esc) {
closeWindow()
}
}
<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">
<ContentTemplate>
<table id="tblAddCustomer" border="0" cellpadding="0" cellspacing="0" width="100%"
runat="server">
<tr>
<td width="26%" align="right">
<asp:Label ID="Label2" runat="server" Text="Customer code" Font-Bold="true" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="tbCustomerCode" runat="server" Width="200px" />
<asp:RequiredFieldValidator ID="rfvCustomerCode" runat="server" ErrorMessage="required!"
ControlToValidate="tbCustomerCode"></asp:RequiredFieldValidator>
</td>
</tr>
</table>
</ContentTemplate>
</telerik:RadWindow>