aspx TextBox not displaying html characters. RRS feed

  • Question

  • I have a web application which has a TextBox:

    <asp:TextBox runat="server" CssClass="form-control monospace" ID="SKEDescriptionTextBox" TextMode="MultiLine" Rows="10" Text='<%# Bind("SKEDescription")%>'  />

    It is bound to a field SKEDescription which is derived from an old mainframe application and is simply text - with no formatting. (old green screen stuff)

    Within the web app the user can change this TextBox and the resultant text gets sent back to the mainframe - after a large amount of code to strip formatting and other characters which will upset the mainframe.

    However if the user enters any text which even looks like html (e.g. <xxx>) then the code fails even before it enters the checking code. This was solved by adding 


    to the TextBox asp: line.

    So now the user can enter <xxx> and it is successfully sent to the mainframe,

    BUT when the screen is redisplayed all the new text is displayed EXCEPT <xxx> - it is not there.

    Is there another method/property of TextBox that controls what is displayed from the Bind source rather than the user input?

    Thursday, September 26, 2019 4:51 PM

All replies

  • Hi TotalTOPS, 

    Thank you for posting here.

    According to your description, your issue is more related to ASP.NET. Therefore, it will be more appropriate to ask your question in ASP.NET Forums.

    The CLR Forum discuss and ask questions about .NET Framework Base Classes (BCL) such as Collections, I/O, Regigistry, Globalization, Reflection. Also discuss all the other Microsoft libraries that are built on or extend the .NET Framework.

    Thank you for your understanding.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, September 27, 2019 1:42 AM
  • Hopefully you are getting good help from the ASP.Net forums but if the user enters <xxx> and that is what is seen by the user then you should be able to use the innerText property of to get the text.

    Okay well here is probably what is happening. If you look at the HTML for this content (here) then <xxx> looks like &lt;xxx&gt;. But when you put the text containing <xxx> into the TextBox it looks like that exactly and <xxx> is unrecognizable as HTML and ignored. I am not sure of the details of your program to be sure how to solve the problem and I assume you already have help from the other forum.

    Sam Hobbs

    Sunday, September 29, 2019 12:24 AM