Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to pass label text to another page
Posted

You can use different state management techniques to accomplish this.

Refer this link:

Transferring page values to another page[^]

or

use a session object

SQL
session("labelcontents") = label.text

then in your next page you can call
SQL
session("labelcontents")
and stick it wherever
 
Share this answer
 
v3
place that text in a session variable like this
session["labeltext"]=label1.Text;


and access this from another page

like this
text is : session["labeltext"].Tostring();
 
Share this answer
 
You can accomplish this through the use of Query Strings or using Session
In the following way:
Response.Redirect("xyz.aspx?label="+label1.text,false);

for accesig this:
string xyz=Request.QueryString["label"].ToString();
 
Share this answer
 
v4
You can use sessions if the text contains some confidential data
otherwise you can send it in querystring.

using session

C#
session["lbl"]=label1.text;


retrieving in 2nd page

C#
string lbl=session["lbl"].tostring();


using Querystring

C#
Response.redirect("secondpageurl.aspx?lbl="+label1.text,false);


you can retrieve as below

C#
string lbl=request.querystring["lbl"].tostring();
 
Share this answer
 
v3
Comments
Uday P.Singh 11-Oct-11 7:50am    
my 5!
Anuja Pawar Indore 11-Oct-11 7:51am    
My 5
P.Salini 11-Oct-11 7:54am    
Thanks to both of you
Dalek Dave 13-Oct-11 3:30am    
Good Answer.
There are so many ways to pass values to another page. See the State Management[^].

In your case, you can use Querystring[^].
 
Share this answer
 
Comments
Uday P.Singh 11-Oct-11 7:49am    
my 5!
You can use the Query Strings or session to accomplish this task.

C#
session["text"]=label1.Text;


http://yoursitename/products.aspx?field1=value1&field2=value2
 
Share this answer
 
v3
Hi,
If you want to pass the values from one form another
1)use parameterized constructor,
2)(Another way)Declare a global variable as public and before calling that just assign the global variable with what u want to pass
 
Share this answer
 
Dear Use Session which is the best option
 
Share this answer
 
This is a popular question about form collaboration. Most robust way is implementing appropriate interface in the form class.

For more details, see my past answer:
How to copy all the items between listboxes in two forms[^].

See also the whole discussion for different options.

—SA
 
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