Sunday, August 22, 2010

How to pass values from parent page to child page [embedded in iframe] in asp.net

Parent Page: - Buy.aspx
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
    <title></title>
    <script runat="server">        
        protected void Buy(object sender, EventArgs e)
        {
            this.ifmContainer.Attributes.Add("src"this.ResolveUrl(
                string.Format("~/Checkout.aspx?p={0}&q={1}"this.txtProduct.Text, this.txtQuantity.Text)));
        }
    </script>
</head>
<body>
    <form id="form2" runat="server">
        Product : <asp:TextBox runat="server" ID="txtProduct" />
        Quentity : <asp:TextBox runat="server" ID="txtQuantity" />
        <asp:Button runat="server" ID="btnBuy" Text="Buy" OnClick="Buy" />
        <iframe runat="server" id="ifmContainer" src="Checkout.aspx">
            <b>Your browser does not support iframes</b>
        </iframe> 
    </form>
</body>
</html>

Child Page: - Checkout.aspx
<%@ Page Language="C#" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script runat="server">    
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.lblProduct.Text = this.Request.QueryString.Get("p");
            this.lblQuentity.Text = this.Request.QueryString.Get("q");            
        }    
    </script>
</head>
<body>
    <form id="form1" runat="server">
        Product: <asp:Label runat="server" ID="lblProduct" />
        Quantity: <asp:Label runat="server" ID="lblQuentity" />
    </form>
</body>
</html>
 

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...