0

I have a column in my database whose value is e.g. "website, deployment,http://www.qihub.scot.nhs.uk, test" and on my webpage I m using asp:Literal control to bind it. If part of this column value is http then how can we automatically make it a hyperlink so that its clickable.

Markup

<p>
     <strong>Tags: </strong>
     <asp:Literal id="m_eventTags"    runat=server />
</p>

private void PopulateForm()
{
   //blabla
   m_eventTags.Text = theReader.GetString(10);
}
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
rumi
  • 3,293
  • 12
  • 68
  • 109
  • can we see your markup? – geedubb May 06 '13 at 16:05
  • if you notice in the question above within double quotes, the URL(http://www.qihub.scot.nhs.uk") is clickable but the rest of it is a plain text. This is what I want for this column – rumi May 06 '13 at 16:21

1 Answers1

0

You haven't shown us your code so it's hard to give an answer, but I suspect that an ternary if coupled with a string.Contains will do the trick:

myValue.Contains("http") ? "<a href='" + myValue + "'>" + myValue + "</a>" : myvalue;

UPDATE: I just noticed that your url is embedded in a string of text. In order to peel out the URL you will probably need to use regex. I found this SO question which will probably help with that.

Community
  • 1
  • 1
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486