Mar 11, 2011, 8:51 PM
[CLOSED] Passing value from Popup window to Parent window is throwing error
Hi,
I would like to know how to pass some information from popup window to parent window. I would like to activate one button event in parent form, from popup window. I have given popup window ID in main page and trying to hide popup window using that window ID, but it is throwing error.
Main Page Code
I would like to know how to pass some information from popup window to parent window. I would like to activate one button event in parent form, from popup window. I have given popup window ID in main page and trying to hide popup window using that window ID, but it is throwing error.
Main Page Code
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e) {
if (!X.IsAjaxRequest) {
CreateTestButtonsAndTextFields();
}
}
public void CreateTestButtonsAndTextFields()
{
Ext.Net.Button btnTest;
Ext.Net.TextField txtFld;
for (int i = 0; i < 3; i++) {
btnTest = new Ext.Net.Button();
btnTest.Text = "Button " + i.ToString();
btnTest.ID = "btn" + i.ToString();
btnTest.Flex = 1;
btnTest.Listeners.Click.Handler = "Ext.net.DirectMethods.LoadWindow(this.id);";
txtFld = new Ext.Net.TextField();
txtFld.ID = "txtfld" + i.ToString();
FieldSet1.Items.Add(btnTest);
FieldSet1.Items.Add(txtFld);
}
}
public void ReloadSpecificInfo(object sender, DirectEventArgs e)
{
//code to refresh
}
[DirectMethod]
public void LoadWindow(string id) {
MyWindow w = new MyWindow() {
ID = "Window1",
Title = "Title " + id
};
w.AutoLoad.Params[0].Value = id;
w.Modal = true;
w.Render();
}
class MyWindow : Window {
private Unit width = new Unit(400);
public override Unit Width {
get {
return this.width;
}
}
private Unit height = new Unit(400);
public override Unit Height {
get {
return this.height;
}
}
private LoadConfig loadConfig;
public override LoadConfig AutoLoad {
get {
if (loadConfig != null) {
return loadConfig;
}
loadConfig = base.AutoLoad;
loadConfig.Url = "TestWindow.aspx";
loadConfig.Params.Add(new Ext.Net.Parameter() {
Name = "id",
Mode = ParameterMode.Value
});
loadConfig.Mode = LoadMode.IFrame;
return loadConfig;
}
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:FormPanel ID="FormPanel1" runat="server">
<Items>
<ext:FieldSet ID="FieldSet1" runat="server" />
<ext:Button ID="btnRefresh" runat="server" Text="Refresh">
<DirectEvents>
<Click OnEvent ="ReloadSpecificInfo"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:FormPanel>
</form>
</body>
</html>
Child Form Code
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text = this.Request["id"];
}
</script>
<script type="text/javascript">
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ext.Net Example</title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Label ID="Label1" runat="server" />
<ext:Button ID="Save" runat="server" Text="Save" Icon="Disk" Width="120">
<Listeners>
<Click Handler="parent.txtfld1.SetValue(Label1.GetValue())" />
</Listeners>
</ext:Button>
<ext:Button ID="btnCancel" runat="server" Text="Cancel" Icon="Cancel" Width="120">
<Listeners>
<Click Handler="#{Window1}.hide()" />
</Listeners>
</ext:Button>
</form>
</body>
</html>
Last edited by Daniil; Mar 15, 2011 at 7:50 AM.
Reason: [CLOSED]