Display HTML on a page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • waqasmgl
    New Member
    • Nov 2007
    • 20

    Display HTML on a page

    Hi,
    I want to display HTML on a page.
    For example:

    If i have following values in a variable:

    Code:
    Dim str As String
    str = <html><body><h1>Hello Html</h1></body></html>
    Then on html page i want to show these exact value not the formated text.

    On page this will appear:
    Code:
    <html><body><h1>Hello Html</h1></body></html>
    Thanx in advance
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    If you send a String containing HTML to the browser, the browser will display the HTML as a web page. But you don't want the HTML to be displayed as a web page, you want it to be displayed as text.

    In order to do this you have to convert all "Reserved HTML characters" (like "<" and ">") into "character entities". Microsoft has been kind enough to provide you with the HtmlEncode method which will convert all HTML reserved characters into character entities for you!

    -Frinny

    Comment

    • waqasmgl
      New Member
      • Nov 2007
      • 20

      #3
      Originally posted by Frinavale
      If you send a String containing HTML to the browser, the browser will display the HTML as a web page. But you don't want the HTML to be displayed as a web page, you want it to be displayed as text.

      In order to do this you have to convert all "Reserved HTML characters" (like "<" and ">") into "character entities". Microsoft has been kind enough to provide you with the HtmlEncode method which will convert all HTML reserved characters into character entities for you!

      -Frinny
      Thank you very much.
      But can i use the same function for javascript?
      i ll try this with javascript too.

      Comment

      • waqasmgl
        New Member
        • Nov 2007
        • 20

        #4
        Thnx all problems solved.

        Comment

        Working...