PDA

View Full Version : [CLOSED] Passing values between tabs autoiframe method



speedstepmem2
Nov 19, 2008, 4:59 AM
I want to pass text value from one tab to another tab. Using javascript...


Default.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

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

<!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 runat="server">
<title>Untitled Page</title>

</head>
<body>
<form id="form1" runat="server">

<ext:ScriptManager ID="ScriptManager1" runat="server">
</ext:ScriptManager>
<br />
<br />
<br />
<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Width="600" Height="250" Plain="true">
<Tabs>
<ext:Tab
ID="Tab1"
runat="server"
Title="Normal Tab"
AutoLoadIFrame="1.aspx"
BodyStyle="padding: 6px;"
AutoScroll="true"
>


</ext:Tab>
<ext:Tab
ID="Tab2"
runat="server"
Title="Closable Tab"
Html="You can close this Tab."
BodyStyle="padding: 6px;"
Closable="true"
/>
<ext:Tab
ID="Tab3"
runat="server"
Title="Ajax Tab"
Html="You can close this Tab."
BodyStyle="padding: 6px;"
AutoScroll="true"
/>
<ext:Tab
ID="Tab4"
runat="server"
Title="Event Tab"
AutoLoadIFrame="2.aspx"
BodyStyle="padding: 6px;"
AutoScroll="true">
<%-- <Content>
<ext:TextField ID="TextField1" runat="server">
</ext:TextField>
</Content>--%>
</ext:Tab>
<ext:Tab
ID="Tab5"
runat="server"
Title="Disabled Tab"
Disabled="true"
Html="Can't see me cause I'm disabled"
AutoScroll="true"
/>
</Tabs>
</ext:TabPanel>
<br />
<br />




</form>
</body>
</html>


1.aspx



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="1.aspx.cs" Inherits="_1" %>

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

<!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 runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function m()
{
parent.window.TabPanel1.setActiveTab(3);
parent.window.TabPanel1.Tab4.TextField1.setValue("Hello worls");
}
</script>
</head>

<body>
<form id="form1" runat="server">

<ext:ScriptManager ID="ScriptManager1" runat="server">
</ext:ScriptManager>
<ext:Button ID="Button1" runat="server" Text="Submit">
<Listeners>
<Click Handler="m()" />
</Listeners>
</ext:Button>


</form>
</body>
</html>



2.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="2.aspx.cs" Inherits="_2" %>

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

<!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 runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">

<ext:ScriptManager ID="ScriptManager1" runat="server">
</ext:ScriptManager>
<ext:TextField ID="TextField1" runat="server">
</ext:TextField>


</form>
</body>
</html>



How to pass the value when i click the button in the tab1 and insert in the tab4 textfield.

Thanks in advance.

Regards
Madan

geoffrey.mcgill
Nov 19, 2008, 8:56 AM
Hi Madan,

Each <iframe> that is created when you set the .AutoLoadIFrame property is set with an id that uses the following pattern: "{TABID}_IFrame"

The id of the <iframe> for the first tab would be "Tab1_IFrame". Once you have an instance of the <iframe>, you can referrence any dom objects on that Page.

The following example demonstrates the full scenario.

Example (Default.aspx)


<%@ Page Language="C#" %>

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

<!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>Untitled Page</title>

</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:TabPanel
ID="TabPanel1"
runat="server"
ActiveTabIndex="0"
Width="600"
Height="250">
<Tabs>
<ext:Tab
ID="Tab1"
runat="server"
Title="Tab 1"
AutoLoadIFrame="Page1.aspx"
/>
<ext:Tab
ID="Tab2"
runat="server"
Title="Tab 2"
AutoLoadIFrame="Page2.aspx"
/>
</Tabs>
</ext:TabPanel>
</form>
</body>
</html>

Example (Page1.aspx)


<%@ Page Language="C#" %>

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

<!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>Untitled Page</title>
<script type="text/javascript">
var sayHello = function () {
parent.window.TabPanel1.setActiveTab(1);
parent.window.Tab2_IFrame.TextField1.setValue('Hel lo World!');
}
</script>
</head>

<body>
<form id="form1" runat="server">

<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:Button ID="Button1" runat="server" Text="Submit">
<Listeners>
<Click Handler="sayHello();" />
</Listeners>
</ext:Button>


</form>
</body>
</html>

Example (Page2.aspx)


<%@ Page Language="C#" %>

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

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">

<ext:ScriptManager ID="ScriptManager1" runat="server" />
<ext:TextField ID="TextField1" runat="server" />


</form>
</body>
</html>


You can also get an instance of the iframe through the Tab or TabPanel properties, but it's a bit convoluted.

Example


// Set via instance of Tab
Tab2.iframe.dom.contentwindow.TextField1.setValue( 'Hello World1');

// Set second Tab in TabPanel
TabPanel1.items.items[1].iframe.dom.contentwindow.TextField1.setValue('tes ting...')

Hope this helps.

speedstepmem2
Nov 20, 2008, 1:11 AM
Hi Geoffrey

It worked thanks man. You r great...

Regards
Madan