?
Solved

How to add hyperlink to aspx label?

Posted on 2009-02-18
5
Medium Priority
?
1,641 Views
Last Modified: 2013-12-17
Hi

I get a string from DB and display on aspx page as label.

I need to add a hyperlink to that label.

How can I do that?

I use VC#
<a href="test.aspx"><asp:Label ID="Label5" runat="server" /></a>

Open in new window

0
Comment
Question by:techques
  • 3
5 Comments
 
LVL 19

Accepted Solution

by:
daveamour earned 900 total points
ID: 23678363
Hi
Not quite sure what it is you need.
Can you show me all the information you have being returned from the database - is it just 1 column or 2?
Also show me what html it is you want ultimatley rendered?
Meanwhile it may be that you just need to use the Hyperlink Control:
<asp:HyperLink ID="MyLink" runat="server"></asp:HyperLink>
Then in code behind you go:
        MyLink.Text = "BBC";
        MyLink.NavigateUrl = http://www.bbc.co.uk;
But of course you put in there the values from your database.
0
 
LVL 8

Assisted Solution

by:isaackhazi
isaackhazi earned 300 total points
ID: 23678369

label.Text = "this text <a href=\"page.aspx?param=x\">link</a>"

Open in new window

0
 
LVL 20

Assisted Solution

by:informaniac
informaniac earned 300 total points
ID: 23678457
@isaackhazi..

I'm not sure if that might work....

coz label will render < as it is. ull have to use < instead something like this...

label.Text = "this text &lt;a href=\"page.aspx?param=x\"&gt;link&lt;/a&gt;"

Open in new window

0
 
LVL 19

Expert Comment

by:daveamour
ID: 23678708
informaniac:
Think you got mixed up a bit.  If you did want to do things using a label and not an actual hyperlink control then < and > are correct. < and > will escape these and output them in the rendered content and not treat them as html tags.
0
 
LVL 19

Expert Comment

by:daveamour
ID: 23689727
Thanks for the points techques but really you shouldn't have accepted what informaniac said as an answer as what he said is completeley 100% wrong!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question