lijunguo
asked on
asp.net post data from one Iframe to another Iframe
Hi Experts,
I have a asp.net page with 2 Iframes(aspx page). One is the list Frame, the other is detail Frame. I have 2 buttons in list Frame, when I click button1, it should post data with query string to detail Iframe, when I click button2, it should post data to itself.
Thanks!
I have a asp.net page with 2 Iframes(aspx page). One is the list Frame, the other is detail Frame. I have 2 buttons in list Frame, when I click button1, it should post data with query string to detail Iframe, when I click button2, it should post data to itself.
Thanks!
ASKER
Hi mplungjan ,
Thanks for you quick reply. I tried that and it's not working. I clarity a little bit. I have a page main.aspx
there are 2 iframes in the main.aspx page.
one is:
<div id="divFontPane" runat="server" style="height:85px; display:block;">
<iframe id="iframeTL" src="IfrmTimeLineList.aspx " runat="server" scrolling="no" style="width: 100%; height: 316px;" marginheight="0px"
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
the other is:
<div id="divTLDetails" runat="server" style="height:85px; display:block;">
<iframe id="IfrmTimeLineDetails" src="IfrmTimeLineDetails.a spx" runat="server" scrolling="no" style="width: 100%; height: 484px;" marginheight="0px"
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
What I'm trying to do is from "IfrmTimeLineList.aspx" frame, I have 2 tds, actually not buttons. When I click td1, it should refresh IfrmTimeLineDetails.aspx page, with 2 query strings. When I click td2, it post back to itself. Hope it's clear for you.
Thanks for you quick reply. I tried that and it's not working. I clarity a little bit. I have a page main.aspx
there are 2 iframes in the main.aspx page.
one is:
<div id="divFontPane" runat="server" style="height:85px; display:block;">
<iframe id="iframeTL" src="IfrmTimeLineList.aspx
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
the other is:
<div id="divTLDetails" runat="server" style="height:85px; display:block;">
<iframe id="IfrmTimeLineDetails" src="IfrmTimeLineDetails.a
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
What I'm trying to do is from "IfrmTimeLineList.aspx" frame, I have 2 tds, actually not buttons. When I click td1, it should refresh IfrmTimeLineDetails.aspx page, with 2 query strings. When I click td2, it post back to itself. Hope it's clear for you.
ASKER
Hi Michel,
I'm trying to use parent.frames['IfrmTimeLin eDetails'] , here is the javascript. It's not working.
function testClick(myLifeId,timeLin eId)
{
var query ="IfrmTimeLineDetails.aspx ?myLifeId= " + myLifeId + "&tid=" + timeLineId;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].acti on = query;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].targ et = "_self"//"IfrmTimeLineDeta ils";
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].subm it;
}
I'm trying to use parent.frames['IfrmTimeLin
function testClick(myLifeId,timeLin
{
var query ="IfrmTimeLineDetails.aspx
parent.window.frames['Ifrm
parent.window.frames['Ifrm
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm
}
1. Show some more HTML instead of runat server
2. what do you mean by "post back to itself"
Show the TD's and the onClick of them and the view source of the html needed.
2. what do you mean by "post back to itself"
Show the TD's and the onClick of them and the view source of the html needed.
ASKER
1. cool. I'll show you more details.
2. <<what do you mean by "post back to itself" >>Means refresh the frame itself.
Here is the main page
<%@ Page Language="VB" Culture="en-au" AutoEventWireup="false" CodeFile="TimeLine_home.as px.vb"
Inherits="TimeLine_home" %>
<%@ Register Src="../Controls/LeftMenu. ascx" TagName="LeftMenu" TagPrefix="uc1" %>
<!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>LifeStory Home Living Memory</title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
</head>
<body style="margin: 0px;">
<form id="form1" runat="server">
<center>
<div style="width: 770px; height: 761px;">
<asp:PlaceHolder ID="headerMenu" runat="server"></asp:Place Holder>
<table width="100%" cellpadding="0" cellspacing="0" style="border: solid 1px #E0E0E0;
text-align: left;" >
<tr>
<td rowspan="5" style="width: 20%; height: 100%;" valign="top">
<uc1:LeftMenu ID="LeftMenu" runat="server" />
</td>
<td class="trHeading" style="height: 20px; table-layout: fixed;" rowspan="" colspan="2">
LifeStory</td>
</tr>
<tr>
<td class="tdBorderLeft" colspan="2" style="height: 25px">
<a href="TimeLine_create.aspx " id="newTimeLine" runat="server" ><img src="../images/add16.gif" alt="Create New Blog" style="border:0px; vertical-align:bottom;" />Create New TimeLine</a>
</td>
</tr>
<tr>
<td class="tdBorderLeft" colspan="2" style="height: 25px">
<div id="divFontPane" runat="server" style="height:85px; display:block;">
<iframe id="iframeTL" src="IfrmTimeLineList.aspx " runat="server" scrolling="no" style="width: 100%; height: 316px;" marginheight="0px"
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
</td>
</tr>
<tr>
<td colspan="2" >
<div id="divTLDetails" runat="server" style="height:85px; display:block;">
<iframe id="IfrmTimeLineDetails" src="IfrmTimeLineDetails.a spx" runat="server" scrolling="no" style="width: 100%; height: 484px;" marginheight="0px"
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
</td>
</tr>
<tr>
<td style="width: 60%; height: 183px;" align="left" valign="top" class="tdBorderLeft">
<br />
</td>
<td align="left" style="width: 20%; height: 183px" valign="top">
</td>
</tr>
</table>
</div>
</center>
</form>
</body>
</html>
list frame page. The link td is generated dynamicly. So we use 2 buttons to do the test.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IfrmTimeLineList .aspx.vb"
Inherits="IfrmTimeLineList " %>
<!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>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" >
function testClick(myLifeId,timeLin eId)
{
//var p = window.parent.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].acti on;
//var c2 = p.
var query ="IfrmTimeLineDetails.aspx ?myLifeId= " + myLifeId + "&tid=" + timeLineId;
//window.open(query,'IfrmT imeLineDet ails');
//document.forms[0].action = query;
//document.forms[0].submit ;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].acti on = query;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].targ et = "_self"//"IfrmTimeLineDeta ils";
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].subm it;
}
</script>
</head>
<body style="margin: 0px;">
<form id="form1" target="IfrmTimeLineDetail s" runat="server">
<div>
<table border="0px" cellpadding="0px" cellspacing="0px" style="padding-left:5px;">
<tr>
<td style="line-height: 25px; height: 25px; width: 610px;">
Show TimeLine By Category<asp:RadioButtonLi st ID="rbltype" runat="Server" AutoPostBack="true" BackColor="transparent"
CssClass="rbl" RepeatDirection="Horizonta l" RepeatLayout="Flow">
<asp:ListItem Selected="true" Value="0">All</asp:ListIte m>
<asp:ListItem Value="1">Location</asp:Li stItem>
<asp:ListItem Value="2">Organization</as p:ListItem >
<asp:ListItem Value="3">Education</asp:L istItem>
<asp:ListItem Value="4">Event</asp:ListI tem>
<asp:ListItem Value="5">Membership</asp: ListItem>
</asp:RadioButtonList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>< /td>
</tr>
<tr>
<td style="width: 610px">
<table id="tblTL" runat="Server" border="1" cellpadding="0" cellspacing="0"></table>
</td>
</tr>
<tr>
<td style="width: 610px">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<input id="Button1" type="button" onclick="parent.frames['If rmTimeLine Details']. document.f orms[0].su bmit;" value="refresh details frame" />
<input id="Button2" type="button" onclick="parent.frames['If rmTimeLine Details']. document.f orms[0].su bmit;" value="reload my self" />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Here is the detail frame page.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IfrmTimeLineDeta ils.aspx.v b"
Inherits="IfrmTimeLineDeta ils" %>
<!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>IfrmTimeLineDetails </title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function popTest(){
//document.getElementById( 'divEdit') .style.dis play='none ';
//document.getElementById( 'divFontPa ne').style .display=' block';
alert("run here");
}
</script>
</head>
<body onload="popTest();" style="margin: 0px;">
<form id="form1" method="get" runat="server">
<div>
<table border="0px" cellpadding="0px" cellspacing="0px" style="padding-left:5px;">
<tr>
<td style="line-height: 25px; height: 25px; width: 610px;">
Show TimeLine details</td>
</tr>
<tr>
<td style="width: 610px">
<table id="tblTL" runat="Server" border="1" cellpadding="0" cellspacing="0"></table>
</td>
</tr>
<tr>
<td style="width: 610px">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
If you need to clarify more, just let me know. It's pretty long page.
Regards,
Lijunguo
2. <<what do you mean by "post back to itself" >>Means refresh the frame itself.
Here is the main page
<%@ Page Language="VB" Culture="en-au" AutoEventWireup="false" CodeFile="TimeLine_home.as
Inherits="TimeLine_home" %>
<%@ Register Src="../Controls/LeftMenu.
<!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>LifeStory Home Living Memory</title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
</head>
<body style="margin: 0px;">
<form id="form1" runat="server">
<center>
<div style="width: 770px; height: 761px;">
<asp:PlaceHolder ID="headerMenu" runat="server"></asp:Place
<table width="100%" cellpadding="0" cellspacing="0" style="border: solid 1px #E0E0E0;
text-align: left;" >
<tr>
<td rowspan="5" style="width: 20%; height: 100%;" valign="top">
<uc1:LeftMenu ID="LeftMenu" runat="server" />
</td>
<td class="trHeading" style="height: 20px; table-layout: fixed;" rowspan="" colspan="2">
LifeStory</td>
</tr>
<tr>
<td class="tdBorderLeft" colspan="2" style="height: 25px">
<a href="TimeLine_create.aspx
</td>
</tr>
<tr>
<td class="tdBorderLeft" colspan="2" style="height: 25px">
<div id="divFontPane" runat="server" style="height:85px; display:block;">
<iframe id="iframeTL" src="IfrmTimeLineList.aspx
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
</td>
</tr>
<tr>
<td colspan="2" >
<div id="divTLDetails" runat="server" style="height:85px; display:block;">
<iframe id="IfrmTimeLineDetails" src="IfrmTimeLineDetails.a
marginwidth="0px" frameborder="0" height="95px"></iframe>
</div>
</td>
</tr>
<tr>
<td style="width: 60%; height: 183px;" align="left" valign="top" class="tdBorderLeft">
<br />
</td>
<td align="left" style="width: 20%; height: 183px" valign="top">
</td>
</tr>
</table>
</div>
</center>
</form>
</body>
</html>
list frame page. The link td is generated dynamicly. So we use 2 buttons to do the test.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IfrmTimeLineList
Inherits="IfrmTimeLineList
<!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>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" >
function testClick(myLifeId,timeLin
{
//var p = window.parent.frames['Ifrm
//var c2 = p.
var query ="IfrmTimeLineDetails.aspx
//window.open(query,'IfrmT
//document.forms[0].action
//document.forms[0].submit
parent.window.frames['Ifrm
parent.window.frames['Ifrm
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm
}
</script>
</head>
<body style="margin: 0px;">
<form id="form1" target="IfrmTimeLineDetail
<div>
<table border="0px" cellpadding="0px" cellspacing="0px" style="padding-left:5px;">
<tr>
<td style="line-height: 25px; height: 25px; width: 610px;">
Show TimeLine By Category<asp:RadioButtonLi
CssClass="rbl" RepeatDirection="Horizonta
<asp:ListItem Selected="true" Value="0">All</asp:ListIte
<asp:ListItem Value="1">Location</asp:Li
<asp:ListItem Value="2">Organization</as
<asp:ListItem Value="3">Education</asp:L
<asp:ListItem Value="4">Event</asp:ListI
<asp:ListItem Value="5">Membership</asp:
</asp:RadioButtonList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><
</tr>
<tr>
<td style="width: 610px">
<table id="tblTL" runat="Server" border="1" cellpadding="0" cellspacing="0"></table>
</td>
</tr>
<tr>
<td style="width: 610px">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<input id="Button1" type="button" onclick="parent.frames['If
<input id="Button2" type="button" onclick="parent.frames['If
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Here is the detail frame page.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IfrmTimeLineDeta
Inherits="IfrmTimeLineDeta
<!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>IfrmTimeLineDetails
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function popTest(){
//document.getElementById(
//document.getElementById(
alert("run here");
}
</script>
</head>
<body onload="popTest();" style="margin: 0px;">
<form id="form1" method="get" runat="server">
<div>
<table border="0px" cellpadding="0px" cellspacing="0px" style="padding-left:5px;">
<tr>
<td style="line-height: 25px; height: 25px; width: 610px;">
Show TimeLine details</td>
</tr>
<tr>
<td style="width: 610px">
<table id="tblTL" runat="Server" border="1" cellpadding="0" cellspacing="0"></table>
</td>
</tr>
<tr>
<td style="width: 610px">
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
If you need to clarify more, just let me know. It's pretty long page.
Regards,
Lijunguo
ASKER
I got some progress, I change this function. the last line should be
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].subm it();
instead of
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].subm it;
Then I could see the 'IfrmTimeLineDetails' frame is refreshed. But it's a postback and the querystring is not working yet.
function testClick(myLifeId,timeLin eId)
{
//var p = window.parent.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].acti on;
//var c2 = p.
var query ="IfrmTimeLineDetails.aspx ?myLifeId= " + myLifeId + "&tid=" + timeLineId;
//window.open(query,'IfrmT imeLineDet ails');
//document.forms[0].action = query;
//document.forms[0].submit ;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].acti on = query;
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].targ et = "_self"//"IfrmTimeLineDeta ils";
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm TimeLineDe tails'].do cument.for ms[0].subm it;
}
simliar
I change this line
<input id="Button1" type="button" onclick="parent.frames['If rmTimeLine Details']. document.f orms[0].su bmit;" value="refresh details frame" />
to
<input id="Button1" type="button" onclick="parent.frames['If rmTimeLine Details']. document.f orms[0].su bmit();" value="refresh details frame" />
It also post back now. The problem is how to pass that query string to that frame.
parent.window.frames['Ifrm
instead of
parent.window.frames['Ifrm
Then I could see the 'IfrmTimeLineDetails' frame is refreshed. But it's a postback and the querystring is not working yet.
function testClick(myLifeId,timeLin
{
//var p = window.parent.frames['Ifrm
//var c2 = p.
var query ="IfrmTimeLineDetails.aspx
//window.open(query,'IfrmT
//document.forms[0].action
//document.forms[0].submit
parent.window.frames['Ifrm
parent.window.frames['Ifrm
//alert(myLifeId + " " + timeLineId);
parent.window.frames['Ifrm
}
simliar
I change this line
<input id="Button1" type="button" onclick="parent.frames['If
to
<input id="Button1" type="button" onclick="parent.frames['If
It also post back now. The problem is how to pass that query string to that frame.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi Michel,
Thanks for your help.
parent.window.frames['Ifrm TimeLineDe tails'].lo cation= query;
It works great!
Regards,
Lijunguo
Thanks for your help.
parent.window.frames['Ifrm
It works great!
Regards,
Lijunguo
Do you mean:
<input type="submit" onClick="this.form.target=
<input type="submit" onClick="this.form.target=
Michel