I want to take care of any html-conversion myself. Is there a way to tell the textbox, that I want it to contain the the text without modifications?I'm not understanding where the conversion is taking place. I have a simple page below that loads a string into textbox and shows it as I've set it. Of course, it's impossible to actuallyshow that in this forum (grrr), but basically I'm setting the text to "< b >Hello< /b >" (no spaces in the tags. It shows the < and > characters in the text box. Is that what you mean?
<%@. Page Language="VB" %>
<script runat="server">
Sub Page_Load()
textbox1.text = "Hello "
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
</form>
</body>
</html>
I will make myself a bit clearer. If I use the code-line:
textbox1.text = "<"
I want the HTML generated to be something like this:
<textbox id=textbox1><</textbox>
As it is now, the result will be:
<textbox id=textbox1><</textbox>
The text is in some way automatically encoded to be displayed as proper HTML. I have problem, 'cause I use Swedish characters as ö and that is automatically encoded to ö. See my problem?
The encoding of < into < in a textbox is normal and conforms to the HTML standard AFAIK.
The TextBox control automatically encodes the text. To get the proper ö, just set the text to a normal string with the special character to avoid double encoding:
simply writing textbox1.Text = "ö" will produce the desired character.
Does this help?
It works with writing just textbox1.Text = "ö", but the problem is that the text to be displayed is already encoded. The text is taken from a file, which has all its text in HTML-format. If there is no way to tell the textbox to display the proper text, is there a way to decode the html into text again (make ö into ö and so on)? If not, I think there are some other (complicated) ways to solve it.
You can try HttpUtility.HtmlDecode.
HttpUtility.HtmlDecode may be what I'm looking for. Thanks.
0 comments:
Post a Comment