This is a migrated thread and some comments may be shown as answers.

RadTextBox, HTML Text, and AJAX

1 Answer 266 Views
Input
This is a migrated thread and some comments may be shown as answers.
Xorcist
Top achievements
Rank 1
Xorcist asked on 14 Jan 2010, 09:12 PM
Typing anything close to HTML into a RadTextBox seems to break it when it goes over the wire. I've tried escaping (encoding) it via javascript in the OnRequestStart, but that didn't seem to work... any ideas on the proper way to handle this (and without using a RadEditor).

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 15 Jan 2010, 12:14 PM
Hi Xorcist,

The problem is caused by security restrictions in the ASP.NET framework and is not directly related to RadTextBox. Please refer to:

http://www.asp.net/learn/whitepapers/request-validation/

Since there is no good and proper way to intercept postbacks and change submitted values on the fly, I can suggest you to use some custom client event (e.g. a button click) and encode values before the actual submit action.

If you prefer using more hackish methods, here are two for you:


1.  Override the  WebForm_OnSubmit  function, which handles all postbacks. For example

http://www.duncangunn.me.uk/dasblog/2008/03/07/InterceptingWebFormOnSubmit.aspx


2. Change the value of the request body on the fly:


<%@ Page Language="C#" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>No Title</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:TextBox ID="TextBox1" runat="server" />
        <asp:Button ID="Button1" runat="server" Text="AJAX" />
    </ContentTemplate>
</asp:UpdatePanel>
 
<script type="text/javascript">
 
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
 
function initializeRequestHandler(sender, args)
{
    var requestBody = args.get_request().get_body();
    //args.get_request().set_body(.................);
}
 
</script>
 
</form>
</body>
</html>



Greetings,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Input
Asked by
Xorcist
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or