Answered by:
How to Add href link to a Label control

Question
-
User-218090889 posted
I have a Label control I wish to use to display variable (Url) from code behind, so I want the url to be clickable
Eg:
string CallbackUrl = "https://Mysite.com"; Label1.Text = CallbackUrl
Please how do I add code to make it href.
Friday, September 11, 2020 12:54 PM
Answers
-
User-218090889 posted
mgebhard
The HyperLink control has a NavigationUrl property that you can set in the code behind. If you are using a label to persist a URL that is used by AJAX or code behind then you'll need to provide more information.For more information:
What I want to do in my situation is to make an API call to initialize payment, the API will create Authorization URL that looks like this
https://Paymentsite.com/uy78h4nop
and the call will return via json response, which I Deserialized using JObject.Parse() to get authorization_url as a variable to be assigned to Label
this is :
string received_authorization_url = data.authorization_url;
Label1.Text= received_authorization_url;So I will like the Label to render the authorization_url on web page as Link to direct user to the payment site.
I have found a solution around that, I did
Response.Redirect(received_authorization_url)
);
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 11, 2020 2:23 PM
All replies
-
User475983607 posted
I have a Label control I wish to use to display variable (Url) from code behind, so I want the url to be clickable
Eg:
string CallbackUrl = "https://Mysite.com"; Label1.Text = CallbackUrl
Please how do I add code to make it href.
Use a standard HyperLink control not a Label. Labels render as spans not links.
Friday, September 11, 2020 12:56 PM -
User-218090889 posted
Use a standard HyperLink control not a Label. Labels render as spans not links.I really need to use label because the Url will always contain variable reference Id that will be generated each time the code makes a API call.
something like this"https://Mysite.com/uy78h4nopp
Friday, September 11, 2020 1:26 PM -
User475983607 posted
I really need to use label because the Url will always contain variable reference Id that will be generated each time the code makes a API call.
something like this"https://Mysite.com/uy78h4nopp
Your response makes little sense. The HyperLink control has a NavigationUrl property that you can set in the code behind. If you are using a label to persist a URL that is used by AJAX or code behind then you'll need to provide more information.
Friday, September 11, 2020 1:36 PM -
User-218090889 posted
The HyperLink control has a NavigationUrl property that you can set in the code behind. If you are using a label to persist a URL that is used by AJAX or code behind then you'll need to provide more information.For more information:
What I want to do in my situation is to make an API call to initialize payment, the API will create Authorization URL that looks like this
https://Paymentsite.com/uy78h4nop
and the call will return via json response, which I Deserialized using JObject.Parse() to get authorization_url as a variable to be assigned to Label
this is :
string received_authorization_url = data.authorization_url;
Label1.Text= received_authorization_url;So I will like the Label to render the authorization_url on web page as Link to direct user to the payment site.
Friday, September 11, 2020 2:02 PM -
User-218090889 posted
mgebhard
The HyperLink control has a NavigationUrl property that you can set in the code behind. If you are using a label to persist a URL that is used by AJAX or code behind then you'll need to provide more information.For more information:
What I want to do in my situation is to make an API call to initialize payment, the API will create Authorization URL that looks like this
https://Paymentsite.com/uy78h4nop
and the call will return via json response, which I Deserialized using JObject.Parse() to get authorization_url as a variable to be assigned to Label
this is :
string received_authorization_url = data.authorization_url;
Label1.Text= received_authorization_url;So I will like the Label to render the authorization_url on web page as Link to direct user to the payment site.
I have found a solution around that, I did
Response.Redirect(received_authorization_url)
);
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, September 11, 2020 2:23 PM