Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 21, 2012 07:06 AM by Song-Tian - MSFT
Aug 17, 2012 07:36 PM|LINK
I am using teh Ajax HTML extender to allow user to type info into a textbox. The input then gets saved into a database. For some reason the links and images are not getting saved correctly into the textbox on page refresh. This is because the"<" symbol is
getting replaced with "<" in the HTML and the ">" symbol is getting replaced with ">".
Which means the following HTML code:
Gets written in the HTML as:
Any idea what the problem is?
Aug 17, 2012 07:52 PM|LINK
OK, I have worked out a temporary fix to the problem. On the page pre-render complete event I do a find and replace for all instances of "<" and ">" and replace them back to being "<" and ">".
But there must be a cleaner way to insure that the textboxes maintain the correct HTML code and not change them in the first place?
What happens if there are other symbols that will get screwed around with that i do not yet know about?
Anyway here is my code:
Protected Sub Page_PreRenderComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRenderComplete
Me.txtHTMLDesc.Text = Me.txtHTMLDesc.Text.Replace("<", "<")
Me.txtHTMLDesc.Text = Me.txtHTMLDesc.Text.Replace(">", ">")
Aug 20, 2012 03:34 AM|LINK
try Server.HtmlDecode and
Aug 21, 2012 07:06 AM|LINK
Then you could js encode before save. And decode when you use from database.
More detail, please refer to: