Monday, March 26, 2012

stringbuilder help

Dim sbRegX As New StringBuilder(HttpUtility.HtmlEncode(txtComments.Text))
sbRegX.Replace("<a>", "<a>")
sbRegX.Replace("</a>", "")
How do I get the attributes of href and target to be encoded?"Aaron" <fromtheweb@.aaronminoo.com> schrieb:
>Dim sbRegX As New StringBuilder(HttpUtility.HtmlEncode(txtComments.Text))
>sbRegX.Replace("<a>", "<a>")
>sbRegX.Replace("</a>", "")
>How do I get the attributes of href and target to be encoded?
Encoded as what?
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried,
I have a text box that could have <a href="http://links.10026.com/?link=yahoo.com"
target="_new">yahoo</a>
With just
sbRegX.Replace("<a>", "<a>")
sbRegX.Replace("</a>", ""</a> )
The output is
<a href="http://links.10026.com/?link=yahoo.com" target="_blank">Yahoo
and the data looks like this
<a href="yahoo.com"
target="_blank">Yahoo</a>,
I need it to look like http://www.yahoo.com with it in a new window.
TIA
Aaron
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@.gmx.at> wrote in message
news:uEsaI%23CIGHA.3944@.tk2msftngp13.phx.gbl...
> "Aaron" <fromtheweb@.aaronminoo.com> schrieb:
> Encoded as what?
> --
> M S Herfried K. Wagner
> M V P <URL:http://dotnet.mvps.org/>
> V B <URL:http://classicvb.org/petition/>
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" <fromtheweb@.aaronminoo.com> wrote in message
news:eGhc$WDIGHA.3728@.tk2msftngp13.phx.gbl...
> Herfried,
> I have a text box that could have <a href="http://links.10026.com/?link=yahoo.com"
> target="_new">yahoo</a>
> With just
> sbRegX.Replace("<a>", "<a>")
> sbRegX.Replace("</a>", ""</a> )
> The output is
> <a href="http://links.10026.com/?link=yahoo.com" target="_blank">Yahoo
> and the data looks like this
> <a href="yahoo.com"
> target="_blank">Yahoo</a>,
>
> I need it to look like http://www.yahoo.com with it in a new window.
> TIA
> Aaron
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@.gmx.at> wrote in message
> news:uEsaI%23CIGHA.3944@.tk2msftngp13.phx.gbl...
>

0 comments:

Post a Comment