Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

asp.net post data from one Iframe to another Iframe

Posted on 2006-05-09
8
Medium Priority
?
1,552 Views
Last Modified: 2012-06-22
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!
0
Comment
Question by:lijunguo
  • 5
  • 3
8 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16638186
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
 
LVL 11

Author Comment

by:lijunguo
ID: 16638250
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
 
LVL 11

Author Comment

by:lijunguo
ID: 16638266
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16638368
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
 
LVL 11

Author Comment

by:lijunguo
ID: 16638427
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
 
LVL 11

Author Comment

by:lijunguo
ID: 16638505
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
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1000 total points
ID: 16638564
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
 
LVL 11

Author Comment

by:lijunguo
ID: 16643861
Hi Michel,
Thanks for your help.
parent.window.frames['IfrmTimeLineDetails'].location= query;
It works great!

Regards,
Lijunguo
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question