stringbuilder help

Discussion in 'ASP .Net' started by Aaron, Jan 23, 2006.

  1. Aaron

    Aaron Guest

    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, Jan 23, 2006
    #1
    1. Advertising

  2. "Aaron" <> schrieb:
    >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?

    --
    M S Herfried K. Wagner
    M V P <URL:http://dotnet.mvps.org/>
    V B <URL:http://classicvb.org/petition/>
    Herfried K. Wagner [MVP], Jan 23, 2006
    #2
    1. Advertising

  3. Aaron

    Aaron Guest

    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

    "Herfried K. Wagner [MVP]" <> wrote in message
    news:uEsaI%...
    > "Aaron" <> schrieb:
    > >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?
    >
    > --
    > M S Herfried K. Wagner
    > M V P <URL:http://dotnet.mvps.org/>
    > V B <URL:http://classicvb.org/petition/>
    Aaron, Jan 23, 2006
    #3
  4. 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" <> wrote in message
    news:eGhc$...
    > 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
    >
    > "Herfried K. Wagner [MVP]" <> wrote in message
    > news:uEsaI%...
    >> "Aaron" <> schrieb:
    >> >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?
    >>
    >> --
    >> M S Herfried K. Wagner
    >> M V P <URL:http://dotnet.mvps.org/>
    >> V B <URL:http://classicvb.org/petition/>

    >
    >
    S. Justin Gengo [MCP], Jan 23, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. H.G.Srivatsa

    string vs stringbuilder

    H.G.Srivatsa, Aug 12, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    17,053
    Richard Grimes [MVP]
    Aug 25, 2005
  2. =?Utf-8?B?SGFuZGk=?=

    no stringbuilder in C#2.0?

    =?Utf-8?B?SGFuZGk=?=, Sep 11, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    994
    =?Utf-8?B?SGFuZGk=?=
    Sep 11, 2004
  3. ESPN Lover

    How to reset a StringBuilder?

    ESPN Lover, Oct 13, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    6,957
    ESPN Lover
    Oct 14, 2004
  4. darrel
    Replies:
    2
    Views:
    473
    Juan T. Llibre
    Jan 28, 2005
  5. =?Utf-8?B?SnVzdGlu?=

    Double Quotes in a stringbuilder

    =?Utf-8?B?SnVzdGlu?=, Mar 17, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    7,900
    Mythran
    Mar 18, 2005
Loading...

Share This Page