stringbuilder help

  • Thread starter Thread starter Aaron
  • Start date Start date
A

Aaron

Dim sbRegX As New StringBuilder(HttpUtility.HtmlEncode(txtComments.Text))

sbRegX.Replace("&lt;a&gt;", "<a>")

sbRegX.Replace("&lt;/a&gt;", "")



How do I get the attributes of href and target to be encoded?
 
Aaron said:
Dim sbRegX As New StringBuilder(HttpUtility.HtmlEncode(txtComments.Text))
sbRegX.Replace("&lt;a&gt;", "<a>")
sbRegX.Replace("&lt;/a&gt;", "")

How do I get the attributes of href and target to be encoded?

Encoded as what?
 
Herfried,

I have a text box that could have <a href="yahoo.com"
target="_new">yahoo</a>

With just
sbRegX.Replace("&lt;a&gt;", "<a>")
sbRegX.Replace("&lt;/a&gt;", ""</a>)

The output is
<a href="yahoo.com" target="_blank">Yahoo
and the data looks like this
&amp;lt;a href=&amp;quot;yahoo.com&amp;quot;
target=&amp;quot;_blank&amp;quot;&amp;gt;Yahoo&lt;/a&gt;,



I need it to look like http://www.yahoo.com with it in a new window.

TIA

Aaron
 
Aaron,

You'll be looking for Server.HtmlEncode and Server.HtmlDecode. You may also
want to experiment (depending on all the uses of the input text) with
Sever.UrlEncode and Server.UrlDecode.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
Aaron said:
Herfried,

I have a text box that could have <a href="yahoo.com"
target="_new">yahoo</a>

With just
sbRegX.Replace("&lt;a&gt;", "<a>")
sbRegX.Replace("&lt;/a&gt;", ""</a>)

The output is
<a href="yahoo.com" target="_blank">Yahoo
and the data looks like this
&amp;lt;a href=&amp;quot;yahoo.com&amp;quot;
target=&amp;quot;_blank&amp;quot;&amp;gt;Yahoo&lt;/a&gt;,



I need it to look like http://www.yahoo.com with it in a new window.

TIA

Aaron
 
Back
Top