// Example.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="_Example" %>
<!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>PostBackUrl Example: how to submit a page to another page in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkSlateBlue"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="Your City" AssociatedControlID="TextBox1"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit in this page" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Submit in city page" PostBackUrl="~/CityPage.aspx" />
</div>
</form>
</body>
</html>
// Example.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
public partial class Example : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text = "Your city name: " +
TextBox1.Text.ToString();
}
}
// city.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="city.aspx.cs" Inherits="_city" %>
<!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>City Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>City Page</h1>
<asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>
</div>
</form>
</body>
</html>
// city.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
public partial class city: System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
TextBox PP_TextBox1;
PP_TextBox1 = (TextBox)PreviousPage.FindControl("TextBox1");
Label1.Text = "Your City: " + PP_TextBox1.Text;
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Example.aspx.cs" Inherits="_Example" %>
<!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>PostBackUrl Example: how to submit a page to another page in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkSlateBlue"></asp:Label>
<br />
<asp:Label ID="Label2" runat="server" Text="Your City" AssociatedControlID="TextBox1"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator>
<br />
<asp:Button ID="Button1" runat="server" Text="Submit in this page" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Submit in city page" PostBackUrl="~/CityPage.aspx" />
</div>
</form>
</body>
</html>
// Example.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
public partial class Example : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text = "Your city name: " +
TextBox1.Text.ToString();
}
}
// city.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="city.aspx.cs" Inherits="_city" %>
<!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>City Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>City Page</h1>
<asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>
</div>
</form>
</body>
</html>
// city.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
public partial class city: System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
TextBox PP_TextBox1;
PP_TextBox1 = (TextBox)PreviousPage.FindControl("TextBox1");
Label1.Text = "Your City: " + PP_TextBox1.Text;
}
}
No comments:
Post a Comment