Write a Program in ASP.NET That When I Enter Value in Home.aspx it Result will give in About.aspx(Response & Redirect).
Go to File -> New -> Project -> Select asp.net web forms application -> Entry Application Name -> Click OK.
STEP:-2 Copy The Code And Paste These Code in Home.aspx.
- <div>
-
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
- <br />
-
- <br />
-
- <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
- <br />
- <br />
-
- <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
- <br />
- <br />
-
- <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
- <br />
- </div>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace WebApplication1
- {
- public partial class _Default : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- Label1.Text = Convert.ToString(Convert.ToInt32(TextBox1.Text) + Convert.ToInt32(TextBox2.Text));
- Session["result"] = Label1.Text;
- Response.Redirect("About.aspx");
- }
- }
- }
STEP:-4 Copy The Code And Paste These Code in About.aspx.
- <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
- <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
- </asp:Content>
STEP:-5 Copy The Code And Paste These Code in About.aspx.cs.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace WebApplication1
- {
- public partial class About : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- Label1.Text = Session["Result"].ToString();
- }
- }
- }

No comments:
Post a Comment