Displaying HTML Docs on a WebPage

Discussion in 'ASP .Net' started by GaryDean, May 8, 2008.

  1. GaryDean

    GaryDean Guest

    I have HTML formatted documents stored in a database. I want to display
    them on a web page. However I see there is no "browser control" in asp (as
    there is in windows forms). This sounds kind of stupid but is there a
    control that I can load HTML into to display in a web page?
    Thanks,
    Gary
    GaryDean, May 8, 2008
    #1
    1. Advertising

  2. GaryDean

    Norm Guest

    On May 7, 5:47 pm, "GaryDean" <> wrote:
    > I have HTML formatted documents stored in a database.  I want to display
    > them on a web page.  However I see there is no "browser control" in asp (as
    > there is in windows forms).  This sounds kind of stupid but is there a
    > control that I can load HTML into to display in a web page?
    > Thanks,
    > Gary


    I would use either a literal control, or a label. Just set the .Text
    property to the HTML from the DB.
    Norm, May 8, 2008
    #2
    1. Advertising

  3. GaryDean

    Cramer Guest

    "Norm" <> wrote in message
    news:...
    On May 7, 5:47 pm, "GaryDean" <> wrote:
    >> I have HTML formatted documents stored in a database. I want to display
    >> them on a web page. However I see there is no "browser control" in asp
    >> (as
    >> there is in windows forms). This sounds kind of stupid but is there a
    >> control that I can load HTML into to display in a web page?
    >> Thanks,
    >> Gary


    >I would use either a literal control, or a label. Just set the .Text
    >property to the HTML from the DB.


    The Literal control allows you to inject text, verbatim, into the response
    stream. As such, any HTML you inject vai the Literal control would be
    something the browser would render. What you can do to prevent the browser
    from rendering the injected HTML is wrap the injected HTML in a <PRE> tag.
    So use the Literal control, but be sure to make use of the <PRE> tag...
    something like this:

    e.g., myLiteral.Text = @"<PRE> html code to display as html code goes
    here</PRE>";
    Cramer, May 8, 2008
    #3
  4. Hello Gary,

    I agree with Norm and Cramer. Apart from theirs, I'd also suggest checking
    whether the HTML string from DB is escaped. Take the following code snippet
    as an example:

    1, this.Label1.Text = "<font color='red'>test</font>";
    This will be rendered as "test" in red as we expected.

    2, this.Label2.Text = "&lt;font color='red'&gt;test&lt;/font&gt;";
    '<' can be encoded as &lt;, and '>' can be encoded as &gt; and be stored
    into the DB. This piece of code will render the string as "<font
    color='red'>test</font>". And I believe this is not what you expected to
    see.

    3, this.Label3.Text = System.Web.HttpUtility.HtmlDecode("&lt;font
    color='red'&gt;test&lt;/font&gt;");
    To resolve the problem in 2, we can use System.Web.HttpUtility.HtmlDecode
    to decode the string, and generate the same effect as 1.

    Please have a try and let us know if the suggestions help.

    Regards,
    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], May 8, 2008
    #4
  5. Hello Gary,

    I agree with Norm and Cramer. Apart from theirs, I'd also suggest checking
    whether the HTML string from DB is escaped. Take the following code snippet
    as an example:

    1, this.Label1.Text = "<font color='red'>test</font>";
    This will be rendered as "test" in red as we expected.

    2, this.Label2.Text = "&lt;font color='red'&gt;test&lt;/font&gt;";
    '<' can be encoded as &lt;, and '>' can be encoded as &gt; and be stored
    into the DB. This piece of code will render the string as "<font
    color='red'>test</font>". And I believe this is not what you expected to
    see.

    3, this.Label3.Text = System.Web.HttpUtility.HtmlDecode("&lt;font
    color='red'&gt;test&lt;/font&gt;");
    To resolve the problem in 2, we can use System.Web.HttpUtility.HtmlDecode
    to decode the string, and generate the same effect as 1.

    Please have a try and let us know if the suggestions help.

    Regards,
    Jialiang Ge (, remove 'online.')
    Microsoft Online Community Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.

    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Jialiang Ge [MSFT], May 8, 2008
    #5
  6. GaryDean

    GaryDean Guest

    Cramer,
    Thanks. The literal control worked great.
    Gary

    --
    Regards,
    Gary Blakely
    Dean Blakely & Associates
    www.deanblakely.com
    "Cramer" <> wrote in message
    news:%...
    >
    > "Norm" <> wrote in message
    > news:...
    > On May 7, 5:47 pm, "GaryDean" <> wrote:
    >>> I have HTML formatted documents stored in a database. I want to display
    >>> them on a web page. However I see there is no "browser control" in asp
    >>> (as
    >>> there is in windows forms). This sounds kind of stupid but is there a
    >>> control that I can load HTML into to display in a web page?
    >>> Thanks,
    >>> Gary

    >
    >>I would use either a literal control, or a label. Just set the .Text
    >>property to the HTML from the DB.

    >
    > The Literal control allows you to inject text, verbatim, into the response
    > stream. As such, any HTML you inject vai the Literal control would be
    > something the browser would render. What you can do to prevent the browser
    > from rendering the injected HTML is wrap the injected HTML in a <PRE> tag.
    > So use the Literal control, but be sure to make use of the <PRE> tag...
    > something like this:
    >
    > e.g., myLiteral.Text = @"<PRE> html code to display as html code goes
    > here</PRE>";
    >
    >
    GaryDean, May 8, 2008
    #6
  7. GaryDean

    GaryDean Guest

    Jialiang,
    The literal control worked. I stored the html as byte[] and then retrieved
    it back and it was not escaped so things are fine.
    Thanks for your help.
    Gary

    --
    Regards,
    Gary Blakely
    Dean Blakely & Associates
    www.deanblakely.com
    "Jialiang Ge [MSFT]" <> wrote in message
    news:...
    > Hello Gary,
    >
    > I agree with Norm and Cramer. Apart from theirs, I'd also suggest checking
    > whether the HTML string from DB is escaped. Take the following code
    > snippet
    > as an example:
    >
    > 1, this.Label1.Text = "<font color='red'>test</font>";
    > This will be rendered as "test" in red as we expected.
    >
    > 2, this.Label2.Text = "&lt;font color='red'&gt;test&lt;/font&gt;";
    > '<' can be encoded as &lt;, and '>' can be encoded as &gt; and be stored
    > into the DB. This piece of code will render the string as "<font
    > color='red'>test</font>". And I believe this is not what you expected to
    > see.
    >
    > 3, this.Label3.Text = System.Web.HttpUtility.HtmlDecode("&lt;font
    > color='red'&gt;test&lt;/font&gt;");
    > To resolve the problem in 2, we can use System.Web.HttpUtility.HtmlDecode
    > to decode the string, and generate the same effect as 1.
    >
    > Please have a try and let us know if the suggestions help.
    >
    > Regards,
    > Jialiang Ge (, remove 'online.')
    > Microsoft Online Community Support
    >
    > Delighting our customers is our #1 priority. We welcome your comments and
    > suggestions about how we can improve the support we provide to you. Please
    > feel free to let my manager know what you think of the level of service
    > provided. You can send feedback directly to my manager at:
    > .
    >
    > ==================================================
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    > ==================================================
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    GaryDean, May 8, 2008
    #7
  8. GaryDean

    bruce barker Guest

    in html, the <iframe> is the same as the browser control. with IE, its an
    actual ie instance hosted on the page.


    -- bruce (sqlwork.com)


    "GaryDean" wrote:

    > I have HTML formatted documents stored in a database. I want to display
    > them on a web page. However I see there is no "browser control" in asp (as
    > there is in windows forms). This sounds kind of stupid but is there a
    > control that I can load HTML into to display in a web page?
    > Thanks,
    > Gary
    >
    >
    >
    bruce barker, May 8, 2008
    #8
    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. Replies:
    1
    Views:
    419
  2. Paul
    Replies:
    14
    Views:
    841
    Alexey Smirnov
    Jun 19, 2008
  3. KYG
    Replies:
    2
    Views:
    883
    Ian Collins
    Aug 18, 2008
  4. Stéphane Wirtel
    Replies:
    0
    Views:
    179
    Stéphane Wirtel
    Apr 19, 2007
  5. Al
    Replies:
    1
    Views:
    150
    Henry Law
    Oct 16, 2005
Loading...

Share This Page