Self-Page and Cross page posting
For Example: Write a program to demonstrate use of cross page posting
WebForm1 Code:
<%@ Page Language="C#"
AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication5.WebForm1"
%>
<html >
<head runat="server">
<title>Aryan Comptuers, Barshi
</title></head>
<body>
<form id="form1"
runat="server">
<center>
<asp:Label ID="Label1"
runat="server" Text="Aryan Computers, Barshi "
Font-Bold="True"
Font-Names="Comic Sans MS" ForeColor="#009933"
style="text-align:
center"></asp:Label>
</center>
<hr />
<hr />
<p> </p>
<center>
<asp:Button ID="Button1"
runat="server" Font-Bold="True"
PostBackUrl="~/WebForm2.aspx"
style="text-align: right"
Text="Go to Next Page" />
</center>
<p> </p>
</form>
</body>
</html>
WebForm2 Code:
<html>
<head runat="server">
<title> Crosss page Posting
</title>
</head>
<body>
<form id="form1"
runat="server">
<div>
<p>
<center>
<asp:Label ID="Label1"
runat="server"
Text="Cross page posting Web-Page"
Font-Bold="True"
Font-Size="XX-Large"
ForeColor="#000099"></asp:Label>
</p>
</center>
</div>
<b> <asp:Label ID="Label3"
runat="server" Text="Data Get From Web-Form First:
"></asp:Label></b>
<asp:Label ID="Label2"
runat="server" Text="Label"></asp:Label>
</form>
</body>
</html>
WebForm1 .aspx.cs Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication5
{
public partial class WebForm1 :
System.Web.UI.Page
{
protected void Page_Load(object sender,
EventArgs e)
{
if (Page.PreviousPage != null)
{
}}}}
WebForm2 .aspx.cs Code:
namespace WebApplication5
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage != null)
{
Button Button1 =
(Button)(Page.PreviousPage.FindControl("Button1"));
Label2.Text = Button1.Text;
}
}
}
}
Output:
Comments
Post a Comment