How do you pass value of a text box from page1.aspx to
page2.aspx without storing it as a session value?

Answer Posted / arif khan

Create Default.aspx

this is my Default.aspx
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>


<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Default page1</h1>
<asp:TextBox ID="txt1" runat="server" />
<asp:Button ID="btn" runat="server" Text="Submit"
OnClick="Transfer_Click" />
</div>
</form>
</body>
</html>

Code file
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Transfer_Click(object sender, EventArgs
e)
{
Server.Transfer("~/Default2.aspx");
}
}


create Default2.aspx

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>Welcome to Default page 2</h1>
<asp:Label ID="lblshow" runat="server"></asp:Label>
</div>
</form>
</body>
</html>

code file

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
TextBox txt = (TextBox)Page.PreviousPage.FindControl
("txt1");
lblshow.Text = txt.Text;
}
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is an interface and what is an abstract class? Please, expand by examples of using both. Explain why?

534


When should I use .net core?

548


What is meant by localization?

630


Explain the difference between vb and vb.net?

576


Tell us the difference between managed and unmanaged code?

519






I have a problem in installing visual Studio 2008 on PC that have Celeron Processor ? afterAll InstallionFaied . Pls suggest me . Is it possible or not .if Yes then How ?

1562


What is the use of system.diagnostics.process class in .net?

532


Explain about Behavioral design pattern?

630


Difference between dispose and finallize method?

659


What is common language specification (cls)?

638


How do you view the methods and members of a dll?

612


Difference between abstract class and interface in .net?

549


What is SOAP? How you will do windows and forms authentication?

576


What is DTS and explain the purpose of it?

586


Explain how to redirect tracing to a file?

549