Click here to Skip to main content
15,909,656 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
like when i login in one page text box that same name come to label in another web page
Posted
Comments
Ashi0891 22-Aug-14 3:50am    
use sessions or pass that value using querystring while redirecting to second web page.
Search on google about these ways, in case you have any problem after that then let us know.
Member 10918596 22-Aug-14 6:03am    
can you give simple example

1. It is simple. Just cache it (into user session), or send (by using query string) the value input into the textbox and used it in the Page_Load event of the other web page to init its label.

2.Example:

C#
//In Page1.aspx.cs
protected void SaveButton_Click(object sender, EventArgs e)
{
 string userName = _userNameTextBox.Text.Trim();
 Session["UserName"] = userName;  //Cache the value!
 //...
}

//In Page2.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
  //Get the user name value from the cache!
  string userName = (Session["UserName"] == null ? string.Empty : (string)Session["UserName"]);
  //
  //Use it for your label.
  _userNameLabel.Text = userName;
} 
//...
}
 
Share this answer
 
v2
Comments
Member 10918596 22-Aug-14 6:03am    
can you give simple example
Raul Iloc 22-Aug-14 6:24am    
See my update in the solution above!
Hi,

There are different techniques to implement this in asp.net. All these are:

(1) Session
(2) Query string
(2) Hidden field.

Now, using query string:

write in Default1.aspx.cs in button click event :

Response.Redirect("Default2.aspx?UserId="+txtUserId.Text);

Then write in the Default2.aspx.cs page where you want to display :

protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
this.label1.Text = Request.QueryString["UserId"];
}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900