PDA

View Full Version : [CLOSED] KeyMap on PopupWindow



elke.schreiber
Aug 06, 2013, 1:34 PM
Hi,

I have a problem with keymap on a pop-up-page.

The scenario is as follows.
The user clicks on a button, a Window comes up, the user enters something and confirm it mit a keymap on enter and the window will be hidden.
But it doesn't work.

EntryPage:

<%@ Page Title="" Language="C#" MasterPageFile="~/TestMaster.Master" AutoEventWireup="true" CodeBehind="popupKeymap.aspx.cs" Inherits="WebCsharp.popupKeymap" %>

<script runat="server">

Ext.Net.Button assume;
Ext.Net.Window win;

protected Ext.Net.KeyMap Key
{
get{
Ext.Net.KeyMap keymap = new Ext.Net.KeyMap(){ID= "KeymapContact", Target = "={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}"};
Ext.Net.KeyBinding binding = new Ext.Net.KeyBinding() { Handler = "#{Assume}.fireEvent('click');" };
binding.Keys.Add(new Ext.Net.Key(){Code= Ext.Net.KeyCode.ENTER});
keymap.Binding.Add(binding);
return keymap;
}
}

protected Ext.Net.Window Win {
get{
win = new Ext.Net.Window(){ID="intCon", Hidden= true};
win.Loader = new Ext.Net.ComponentLoader() { Mode = Ext.Net.LoadMode.Frame };
win.Loader.AutoLoad = false;
win.Bin.Add(Key);
win.Buttons.Add(Assume);
return win;
}
}

protected Ext.Net.Button Assume
{
get
{
assume = new Ext.Net.Button() { ID = "Assume", Text = "Assume" };
return assume;
}
}



protected void Page_Load(object sender, EventArgs e) {

this.Controls.Add(Win);
assume.DirectClick += GetValueFromPopUp;

}

protected void GetValueFromPopUp(object sender, DirectEventArgs e) {

X.Msg.Alert("Status", "Changes saved successfully.", new JFunction { Fn = "showResult" }).Show();
win.Hidden = true;

}

protected void cmdPopUp(object sender, DirectEventArgs e) {
String url = "/SimpleInputForm.aspx";
win.LoadContent(url);
win.Hidden = false;
}
</script>






<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<ext:FormPanel ID="panelEventDetail" runat="server" Padding="0" Border="false" Layout="FitLayout">
<TopBar>
<ext:Toolbar ID="Toolbar1" runat="server" Flat="false">
<Items>
<ext:ToolbarFill />
<ext:Button ID="buttonComplaint" runat="server" Text="PopUp" >
<DirectEvents>
<Click OnEvent="cmdPopUp">
<EventMask ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:FormPanel>
</asp:Content>


MasterPage;

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="TestMaster.master.cs" Inherits="WebCsharp.TestMaster" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>


<script>
var showResult = function (btn) {
Ext.Msg.notify("Button Click", "You clicked the " + btn + " button");
};
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Debug" DisableViewState="False" StateProvider="Cookie"></ext:ResourceManager>
<ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
<Items>
<ext:Panel ID="PanelMaster" runat="server" Layout="FitLayout" Border="true" Region="Center">
<Content>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server" />
</Content>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>


PopupWindow:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SimpleInputForm.aspx.cs" Inherits="WebCsharp.SimpleInputForm" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>Input Mask - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />


<ext:Panel ID="pl"
runat="server"
Title="Input Mask"
Closable="false"
Layout="Form"
BodyPadding="5">
<Defaults>
<ext:Parameter Name="LabelWidth" Value="50" />
</Defaults>
<Items>
<ext:TextField ID="TextField1" runat="server" Note="(999) 999-9999" FieldLabel="Phone">
</ext:TextField>


</Items>
</ext:Panel>
</form>
</body>
</html>

Hope you can help me

Elke

Daniil
Aug 06, 2013, 3:23 PM
Hi Elke,

This one the parent page

Target = "={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}"
doesn't make sense for an iframe, since it has its own body and document.

You could define a KeyMap in the popup page.

Another problem is submitting the TextField's value to the parent page. It is achievable as you wanted to do it.

You can do it via the parent page's DirectMethod.

To call it from an iframe, you can use:

parent.App.direct.Submit(App.TextField1.getValue() );

There is another problem you will probably face with a single TextField on the page and pressing Enter when it is focused.
http://forums.ext.net/showthread.php?22424

elke.schreiber
Aug 09, 2013, 1:42 PM
Hi Elke,

This one the parent page

Target = "={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}"
doesn't make sense for an iframe, since it has its own body and document.

You could define a KeyMap in the popup page.

Another problem is submitting the TextField's value to the parent page. It is achievable as you wanted to do it.

You can do it via the parent page's DirectMethod.

To call it from an iframe, you can use:

parent.App.direct.Submit(App.TextField1.getValue() );

There is another problem you will probably face with a single TextField on the page and pressing Enter when it is focused.
http://forums.ext.net/showthread.php?22424


Hi Danil,

mercy for your answer.
I tried to put the keymap in the Iframe but it doesn't works. Only when I click first in the margin of the page the keymap event is fired.

mfg
Elke

Daniil
Aug 09, 2013, 2:28 PM
Please provide a new test case.