asp.net Cross-Page PostBack
Create CrossPagePostBack.aspx
<%@ Page Language="C#" %> <script runat="server"> </script> <title>asp.net cross page postback example</title> <form id="form1" runat="server"> <div> <h2 style="color: red;"> asp.net Cross-Page PostBack example</h2> <asp:label forecolor="DodgerBlue" id="Label1" runat="server" text="ProductID"> </asp:label> <asp:textbox backcolor="DodgerBlue" forecolor="AliceBlue" id="TextBox1" runat="server"> </asp:textbox> <asp:label forecolor="DodgerBlue" id="Label2" runat="server" text="Product Name"> </asp:label> <asp:textbox backcolor="DodgerBlue" forecolor="AliceBlue" id="TextBox2" runat="server"> </asp:textbox> <asp:button font-bold="true" forecolor="DodgerBlue" id="Button1" postbackurl="~/NextPage.aspx" runat="server" text="Submit data"></asp:button></div> </form>Create NextPage.aspx
<%@ Page Language="C#" %> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { TextBox pvProductID = (TextBox)PreviousPage.FindControl("TextBox1"); TextBox pvProductName = (TextBox)PreviousPage.FindControl("TextBox2"); Label1.Text ="You came from: "+ PreviousPage.Title.ToString(); Label2.Text = "Product ID: " + pvProductID.Text.ToString(); Label2.Text += " Product Name: " + pvProductName.Text.ToString(); string imageSource = "~/Images/" + pvProductID.Text + ".jpg"; Image1.ImageUrl = imageSource; Image1.BorderWidth = 2; Image1.BorderColor = System.Drawing.Color.DodgerBlue; } </script> <title>asp.net Cross-Page PostBack example: how to submit a page to another page</title> <form id="form1" runat="server"> <div> <h2 style="color: teal;"> asp.net cross page postback example</h2> <asp:label forecolor="Crimson" id="Label1" runat="server"> </asp:label> <asp:label forecolor="SeaGreen" id="Label2" runat="server"> </asp:label> <asp:image id="Image1" runat="server"> </asp:image></div> </form>
asp.net Cross-Page PostBack
Reviewed by vishal
on
5:54 AM
Rating: