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 ">".
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(">", ">")
End Sub
TonyLoco23
Member
79 Points
57 Posts
HTMLExtender not saving HTML links and embedded images correctly
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:
<img src="image.jpg">
Gets written in the HTML as:
<img src="image.jpg">
Any idea what the problem is?
TonyLoco23
Member
79 Points
57 Posts
Re: HTMLExtender not saving HTML links and embedded images correctly
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(">", ">") End Subchetan.sarod...
All-Star
65749 Points
11148 Posts
Re: HTMLExtender not saving HTML links and embedded images correctly
Aug 20, 2012 03:34 AM|LINK
try Server.HtmlDecode and Server.HtmlEncode
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.
Song-Tian - ...
All-Star
43697 Points
4304 Posts
Microsoft
Re: HTMLExtender not saving HTML links and embedded images correctly
Aug 21, 2012 07:06 AM|LINK
Hi,
Then you could js encode before save. And decode when you use from database.
More detail, please refer to: http://msdn.microsoft.com/en-us/library/system.web.httputility.urldecode.aspx.
Feedback to us
Develop and promote your apps in Windows Store