Help with Encoding my String

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to change this method to Encode the text so that it covers situations
where for example below, it's showing the link as an inline text instead of a
link which should be clickable:

example string and what it's showing when rendered:

Stay tuned next week for part two of this series. Check out <a
href="http://www.la-cucina-italiana.com">www.la-cucina-italiana.com</a> to
learn more about Maria and her work.

So that should be encoded to show www.la-cucina-italiana.com as a link.

So in here, I want to encode the incoming text to cover those situations
with inline links.

protected string GetLinkText(string title)
{
return String.Format("{0}", title);

}

I tried something like this but obviously I'm not doing this right: return
Server.HtmlEncode(String.Format("{0}", title)).ToString;
 
Well, tried this, guess it isn't the right way to fix what I'm trying to fix:


protected string GetLinkText(string textvalue)
{
String strval = String.Format("{0}", textvalue);
Server.HtmlEncode(strval);
return strval;
}

The output example below still shows the link as text:

Stay tuned next week for part two of this series. Check out <a
href="http://www.la-cucina-italiana.com">www.la-cucina-italiana.com</a> to
learn more about Maria and her work.
 
dba123 said:
I want to change this method to Encode the text so that it covers situations
where for example below, it's showing the link as an inline text instead of a
link which should be clickable:

example string and what it's showing when rendered:

Stay tuned next week for part two of this series. Check out <a
href="http://www.la-cucina-italiana.com">www.la-cucina-italiana.com</a> to
learn more about Maria and her work.

So that should be encoded to show www.la-cucina-italiana.com as a link.

I'm not at all sure what you mean by "encoded" here. You'll only get
things as a link if you're using a control of some description which
understands HTML - but you haven't told us anything about the context
in which you want to use this text. Could you give us more background?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top