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!
LVL 11
lijunguoAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
1. I cannot run your html since it is full of ASP - I need to see what you get when you type view-source:http.... yourpage.asp

2. I do not understand what you mean
You have
parent.window.frames['IfrmTimeLineDetails'].document.forms[0].action = query;

does that not dow what you need?

If not, use
parent.window.frames['IfrmTimeLineDetails'].location= query;
and drop the submit
0
 
Michel PlungjanIT ExpertCommented:
Querystring is GET, not POST

Do you mean:

<input type="submit" onClick="this.form.target='iframe2'" value="Iframe2">
<input type="submit" onClick="this.form.target='_self'" value="Iframe1">

Michel
0
 
lijunguoAuthor Commented:
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.aspx" 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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
lijunguoAuthor Commented:
Hi Michel,
I'm trying to use parent.frames['IfrmTimeLineDetails'], here is the javascript. It's not working.

    function testClick(myLifeId,timeLineId)
    {
       
        var query ="IfrmTimeLineDetails.aspx?myLifeId=" + myLifeId + "&tid=" + timeLineId;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].action = query;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].target = "_self"//"IfrmTimeLineDetails";
        //alert(myLifeId + "   " + timeLineId);
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].submit;
    }
0
 
Michel PlungjanIT ExpertCommented:
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.
0
 
lijunguoAuthor Commented:
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.aspx.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:PlaceHolder>
                <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> &nbsp;&nbsp;
                        </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.aspx" 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 />
                            &nbsp;
                        </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,timeLineId)
    {
        //var p = window.parent.frames['IfrmTimeLineDetails'].document.forms[0].action;
        //var c2 = p.
       
        var query ="IfrmTimeLineDetails.aspx?myLifeId=" + myLifeId + "&tid=" + timeLineId;
        //window.open(query,'IfrmTimeLineDetails');
        //document.forms[0].action = query;
        //document.forms[0].submit;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].action = query;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].target = "_self"//"IfrmTimeLineDetails";
        //alert(myLifeId + "   " + timeLineId);
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].submit;
    }
</script>

</head>
<body   style="margin: 0px;">
    <form id="form1"  target="IfrmTimeLineDetails" 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:RadioButtonList ID="rbltype" runat="Server" AutoPostBack="true" BackColor="transparent"
                            CssClass="rbl" RepeatDirection="Horizontal" RepeatLayout="Flow">
                            <asp:ListItem Selected="true" Value="0">All</asp:ListItem>
                            <asp:ListItem Value="1">Location</asp:ListItem>
                            <asp:ListItem Value="2">Organization</asp:ListItem>
                            <asp:ListItem Value="3">Education</asp:ListItem>
                            <asp:ListItem Value="4">Event</asp:ListItem>
                            <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">
                       
                        &nbsp;<asp:GridView ID="GridView1" runat="server">
                        </asp:GridView>
                        <input id="Button1" type="button" onclick="parent.frames['IfrmTimeLineDetails'].document.forms[0].submit;" value="refresh details frame" />
                        <input id="Button2" type="button" onclick="parent.frames['IfrmTimeLineDetails'].document.forms[0].submit;" value="reload my self" />
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>

Here is the detail frame page.

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="IfrmTimeLineDetails.aspx.vb"
    Inherits="IfrmTimeLineDetails" %>

<!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.display='none';
    //document.getElementById('divFontPane').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">
                       
                        &nbsp;<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


0
 
lijunguoAuthor Commented:
I got some progress, I change this function. the last line should be
parent.window.frames['IfrmTimeLineDetails'].document.forms[0].submit();
instead of
parent.window.frames['IfrmTimeLineDetails'].document.forms[0].submit;

Then I could see the 'IfrmTimeLineDetails' frame is refreshed. But it's a postback and the querystring is not working yet.

 function testClick(myLifeId,timeLineId)
    {
        //var p = window.parent.frames['IfrmTimeLineDetails'].document.forms[0].action;
        //var c2 = p.
       
        var query ="IfrmTimeLineDetails.aspx?myLifeId=" + myLifeId + "&tid=" + timeLineId;
        //window.open(query,'IfrmTimeLineDetails');
        //document.forms[0].action = query;
        //document.forms[0].submit;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].action = query;
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].target = "_self"//"IfrmTimeLineDetails";
        //alert(myLifeId + "   " + timeLineId);
        parent.window.frames['IfrmTimeLineDetails'].document.forms[0].submit;
    }


simliar
I change this line
<input id="Button1" type="button" onclick="parent.frames['IfrmTimeLineDetails'].document.forms[0].submit;" value="refresh details frame" />
to
<input id="Button1" type="button" onclick="parent.frames['IfrmTimeLineDetails'].document.forms[0].submit();" value="refresh details frame" />

It also post back now. The problem is how to pass that query string to that frame.

0
 
lijunguoAuthor Commented:
Hi Michel,
Thanks for your help.
parent.window.frames['IfrmTimeLineDetails'].location= query;
It works great!

Regards,
Lijunguo
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.