how to delimit html markup characters for a web control

Discussion in 'ASP .Net' started by Tim Zych, Nov 20, 2005.

  1. Tim Zych

    Tim Zych Guest

    I have a code library that I developed in ASP.Net. The code displays in a
    web form via a System.Web.UI.WebControls.Label.

    It works well because I can search for code snippets and then highlight the
    searched results by wrapping color tags around them much like the result
    google provides when you search.

    However, I tried to save the function I used to perform that action, and it
    has characters such as "<", "/" and ">", and the control doesn't display
    them. I suppose it's interpreting them as html and applying them to the html
    control.

    How do I display markup characters in a web control? Is there some sort of
    delimiter? I know next to nothing about html.

    thanks
     
    Tim Zych, Nov 20, 2005
    #1
    1. Advertisements

  2. "Tim Zych" <> wrote in
    news::

    > I have a code library that I developed in ASP.Net. The code
    > displays in a web form via a System.Web.UI.WebControls.Label.
    >
    > It works well because I can search for code snippets and then
    > highlight the searched results by wrapping color tags around
    > them much like the result google provides when you search.
    >
    > However, I tried to save the function I used to perform that
    > action, and it has characters such as "<", "/" and ">", and the
    > control doesn't display them. I suppose it's interpreting them
    > as html and applying them to the html control.
    >
    > How do I display markup characters in a web control? Is there
    > some sort of delimiter? I know next to nothing about html.


    Tim,

    Use HttpUtility.HtmlEncode to convert characters like "<", "/" and
    ">" to their "displayable" equivalents (&lt; for <, &gt; for >, etc.)

    --
    Hope this helps.

    Chris.
    -------------
    C.R. Timmons Consulting, Inc.
    http://www.crtimmonsinc.com/
     
    Chris R. Timmons, Nov 21, 2005
    #2
    1. Advertisements

  3. Tim Zych

    Tim Zych Guest

    thanks!

    "Chris R. Timmons" <crtimmons@X_NOSPAM_Xcrtimmonsinc.com> wrote in message
    news:Xns9714C1C7C95A3crtimmonscrtimmonsin@207.46.248.16...
    > "Tim Zych" <> wrote in
    > news::
    >
    > > I have a code library that I developed in ASP.Net. The code
    > > displays in a web form via a System.Web.UI.WebControls.Label.
    > >
    > > It works well because I can search for code snippets and then
    > > highlight the searched results by wrapping color tags around
    > > them much like the result google provides when you search.
    > >
    > > However, I tried to save the function I used to perform that
    > > action, and it has characters such as "<", "/" and ">", and the
    > > control doesn't display them. I suppose it's interpreting them
    > > as html and applying them to the html control.
    > >
    > > How do I display markup characters in a web control? Is there
    > > some sort of delimiter? I know next to nothing about html.

    >
    > Tim,
    >
    > Use HttpUtility.HtmlEncode to convert characters like "<", "/" and
    > ">" to their "displayable" equivalents (&lt; for <, &gt; for >, etc.)
    >
    > --
    > Hope this helps.
    >
    > Chris.
    > -------------
    > C.R. Timmons Consulting, Inc.
    > http://www.crtimmonsinc.com/
     
    Tim Zych, Nov 21, 2005
    #3
    1. Advertisements

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. Michal A. Valasek

    How to strip HTML markup from string?

    Michal A. Valasek, Aug 9, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,472
    Yan-Hong Huang[MSFT]
    Aug 12, 2003
  2. Matthew Louden
    Replies:
    1
    Views:
    7,654
    Scott M.
    Oct 11, 2003
  3. Reny J Joseph Thuthikattu
    Replies:
    1
    Views:
    837
    =?Utf-8?B?UHJha2FzaC5ORVQ=?=
    Dec 30, 2004
  4. Stefan Mueller
    Replies:
    3
    Views:
    34,296
    Stefan Mueller
    Jul 23, 2006
  5. Andreas Prilop
    Replies:
    0
    Views:
    477
    Andreas Prilop
    May 30, 2005
  6. Replies:
    17
    Views:
    569
  7. Neil8Ken

    Many &nbsp; characters added to markup

    Neil8Ken, Apr 23, 2008, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    869
    Neil8Ken
    Apr 23, 2008
  8. Mike G.
    Replies:
    1
    Views:
    205
    Tad McClellan
    Aug 19, 2003
Loading...