HTML Encode in Formview

Results 1 to 6 of 6

Thread: HTML Encode in Formview

  1. #1
    Join Date
    Dec 1969
    Posts
    132

    Default HTML Encode in Formview

    I am pulling data from SQL 2000 Text fields and displaying in ASP.NET 2.0. The thing is that the data has HTML formatting tags embedded in the data because it is displayed as a web page in another app. I am using a formview to show this data. If I display it in the asp label control - the default control for the formview - the HTML is read and the data displayed correctly with the HTML formatting. However, the text can be rather long and it really needs scroll bars to display it properly. But, if I use a multiline text control to hold the text, the HTML tags are displayed as part of the text, and are not formatted. i.e. &#060;html&#062;&#060;body&#062;&#060;font&#062;&# 060;b&#062;THE BODY OF THE TEXT <BR>Is there a way or a different control that could be used to 1. Provide Scrolling for this text 2.Display the text as HTML. <BR><BR>Thanks in advance, <BR><BR>Dave

  2. #2
    Join Date
    Dec 1969
    Posts
    10,852

    Default RE: HTML Encode in Formview

    Sure...Put the label in a div (though with that much text, it would really probably be more technically correct to use a literal instead of a label.) <BR><BR>Use CSS to define the hight and the width that you want the div to be, and set its scrollable property (again in CSS) to true.

  3. #3
    Join Date
    Dec 1969
    Posts
    132

    Default RE: HTML Encode in Formview

    The label is not the problem. In the database the text is stored with HTML tags ( &#060;html&#062;&#060;body&#062;Text,etc., etc &#060;/body&#062;&#060;/html&#062; ) When I display this in a label in a formview template the HTML is processed and the text displayed with whatever formatting the HTML represents. But that is shown in a very long column with no scroll bars. If I change the control in the formview template to a multiline text box, I get the scroll bars but the text is displayed with all the HTML tags shown as plain text. I need to have the text in the textbox process the tags and not show them.<BR><BR><BR>This includes scroll bars but displays HTML as plain text<BR>&#060;asp:TextBox ID="TextBox1" runat="server" Font-Names="Verdana" Font-Size="XX-Small" Height="180px" Text=<BR>&#039;&#060;%# Bind("BG_DEV_COMMENTS"&#062;&#039;<BR>TextMode="Mu ltiLine"Width="352px"&#062;&#060;/asp:TextBox&#062;<BR><BR>This uses the HTML formatting but has no scroll bars.<BR>&#060;asp:Label ID="BG_DEV_COMMENTSLabel" runat="server" Text=&#039;&#060;%# Bind("BG_DEV_COMMENTS") %&#062;&#039; Font-Names="Verdana" Font-Size="X-Small"&#062;&#060;/asp:Label

  4. #4
    Join Date
    Dec 1969
    Posts
    10,852

    Default Did you read my answer?

    I gave you the solution.


  5. #5
    Join Date
    Dec 1969
    Posts
    10,852

    Default Here's an example.

    &#060;div style="height:200px;width:200px;overflow:auto;bord er-width:1px;border-style:solid;"&#062;<BR>&#060;asp:literal ID="BG_DEV_COMMENTSLabel" runat="server" Text=&#039;&#060;%# Bind("BG_DEV_COMMENTS") %&#062;&#039; Font-Names="Verdana" Font-Size="X-Small" /&#062;<BR>&#060;/div&#062;

  6. #6
    Join Date
    Dec 1969
    Posts
    132

    Default RE: Here's an example.

    I guess that will teach me to read the replies carefully. This is just what I needed, <BR><BR>Thanks and Sorry!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •