
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve
asked on 12 Jan 2011, 02:39 PM
I want to send editor html content up to a webservice, but the content is mangling my request
Can I encode it somehow in the editor?...
Can I encode it somehow in the editor?...
3 Answers, 1 is accepted
0
Hi Steve,
The content obtained from RadEditor on the server is a simple string which you can easily modify using the server-side String.Replace method.
For example to replace the < entity with the < symbols use
string content = Telerik.Web.UI.Editor.ContentEncoder.Decode(Request["RadEditor1"]);
content = content.Replace("<","<");
content = content.Replace(">",">");
content = content.Replace("&","&");
You can also use the code below to encode the special tags and symbols in HTML content:
You can use these functions to solve the problem. More information is available in this forum thread: Get HTML content using Request.Form.
All the best,
Rumen
the Telerik team
The content obtained from RadEditor on the server is a simple string which you can easily modify using the server-side String.Replace method.
For example to replace the < entity with the < symbols use
string content = Telerik.Web.UI.Editor.ContentEncoder.Decode(Request["RadEditor1"]);
content = content.Replace("<","<");
content = content.Replace(">",">");
content = content.Replace("&","&");
You can also use the code below to encode the special tags and symbols in HTML content:
internal class ContentEncoder |
{ |
static ContentEncoder() |
{ |
_characters = new char[] {'%', '<', '>', '!', '"', '#', '$', '&', '\'', '(', ')', ',', ':', |
';', '=', '?', '[', '\\', ']', '^', '`', '{', '|', '}', '~', '+'}; |
_characterBytes = Encoding.ASCII.GetBytes(_characters); |
} |
private static char[] _characters; |
private static byte[] _characterBytes; |
public static string Encode(string text) |
{ |
for (int i=0; i<_characterBytes.Length; i++) |
{ |
text = text.Replace(_characters[i].ToString(), "%" + _characterBytes[i].ToString("x")); |
} |
return text; |
} |
public static string Decode(string text) |
{ |
for (int i=_characterBytes.Length - 1; i>=0; i--) |
{ |
text = text.Replace("%" + _characterBytes[i].ToString("x"), _characters[i].ToString()); |
} |
return text; |
} |
} |
You can use these functions to solve the problem. More information is available in this forum thread: Get HTML content using Request.Form.
All the best,
Rumen
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0

sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Jan 2011, 03:18 PM
Hey Rumen,
It's not the serverside that's an issue, it's getting the .get_html(true), putting it into a javascript object and sending it up to a webservice to be consumed that I'm having problems with...
It's not the serverside that's an issue, it's getting the .get_html(true), putting it into a javascript object and sending it up to a webservice to be consumed that I'm having problems with...
0
Hi Steve,
Thank you for the clarification.
Please, try the suggestions provided in the following articles which could be helpful for your scenario:
Encoding html using javascript's escape & unescape,
Neat little HTML encoding trick in javascript
and
Client side HTML encoding and decoding.
I hope this helps.
Kind regards,
Rumen
the Telerik team
Thank you for the clarification.
Please, try the suggestions provided in the following articles which could be helpful for your scenario:
Encoding html using javascript's escape & unescape,
Neat little HTML encoding trick in javascript
and
Client side HTML encoding and decoding.
I hope this helps.
Kind regards,
Rumen
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.