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:

iPhone Launch Screen Sizes

iPhone Portrait iOS 8 Retina HT 5.5 = 1242 X 2208 Retna HD 4.7 = 750 X 1134 iPhone Landscape iOS 8 Retina HD 5.5  2208 X 1242 iPho...