Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Most of c# query string tutorial using textbox to create a query string depending on text entered in it, But instead of text box can we create a query string of label text as in my application i have label show the UserID and i need to store this UserID into a query string to pass it to another page so if it possible how we can do that??!!
Posted
Comments
BillWoodruff 7-Dec-14 21:50pm    
This sounds very simple: if you set the 'Text property of the Label, then you know what the 'Text is: so, either access it by yourLabel.Text, or create a string variable to hold the Text, and then assign the Text to the Label.
syed shanu 8-Dec-14 2:09am    
What is your problem to pass label text insted of textbox in query string.

As Bill said, it's as simple as getting the text from the label and then putting it into the querystring:

C#
String labelValue = label1.Text;
String queryString = "yoururl.aspx?" + Server.UrlEncode(labelValue);
 
Share this answer
 
C#
String lblValue=lblUserID.Text;
String quesryString="Home.aspx?uid='"+lblValue+"'";
 
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