We are still using the old, ASP.NET, non-AJAXified verison of the RadEditor (due to issues we have with getting the newer version to appear correctly on our website's pages). There are a couple of things I'd like to do that seem from the forums only to be do-able via the Telerik control's javascript libraries, but I'm having trouble figuring out how to use those in the old version of the tool (where the libraries were not consolidated and accessible via the $ symbol as they are post-Prometheus release). Here's what I'm looking to do:
1) Check the length of strings being entered into the control, and limit the length to a set number of characters (including the HTML markup) (or, even more ideally, but maybe harder - not limit the allowed length, but detect it and show a warning if a set length is exceeded - but not with a popup but rather by just updating text of a control on the page to show the warning / not show the warning on paste and keystroke). I see the post at http://www.telerik.com/community/forums/aspnet-ajax/editor/maximum-text-length.aspx , but it depends on the $ javascript library
2) Capture the paste event and pop up a window offering to strip ALL formatting from the pasted content (not just MS Word formatting), and based on the user's choice either leave the pasted content intact or strip all. I see the posts on this that point to
1) Check the length of strings being entered into the control, and limit the length to a set number of characters (including the HTML markup) (or, even more ideally, but maybe harder - not limit the allowed length, but detect it and show a warning if a set length is exceeded - but not with a popup but rather by just updating text of a control on the page to show the warning / not show the warning on paste and keystroke). I see the post at http://www.telerik.com/community/forums/aspnet-ajax/editor/maximum-text-length.aspx , but it depends on the $ javascript library
2) Capture the paste event and pop up a window offering to strip ALL formatting from the pasted content (not just MS Word formatting), and based on the user's choice either leave the pasted content intact or strip all. I see the posts on this that point to
Telerik.Web.DomElement.addExternalHandler as the javascript library to call (pre the introduction of the $ library), but when I try to call this, I get a popup saying "Exception while executing client event "OnClientLoad" Error: 'Telerik' is undefined." so basically I'm not referencing the library right, but I'm not sure how to do so correctly.
Many thanks for your aid!
FYI, Here's the code for my test application page that throws the exception cited above:
| <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TelerikTest2._Default" %> |
| <%@ Register TagPrefix="telerik" Namespace="Telerik.WebControls" Assembly="RadEditor.Net2" %> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" > |
| <head runat="server"> |
| <title></title> |
| </head> |
| <body> |
| <form id="form1" runat="server"> |
| <div> |
| <script type="text/javascript"> |
| function OnClientLoad(editor, args) |
| { |
| var element = document.all; |
| Telerik.Web.DomElement.addExternalHandler(element, "paste", function(e) { |
| window.setTimeout(function() { |
| //write here your code which you want to execute when the paste event is fired |
| //after that execute the editor's clean filters |
| var oSelElem = editor.get_html(); |
| alert(oSelElem); |
| editor.fire("SelectAll"); |
| editor.fire("FormatStripper", { value: "FONT" }); |
| editor.fire("FormatStripper", { value: "SPAN" }); |
| editor.fire("FormatStripper", { value: "CSS" }); |
| alert(editor.get_html()); |
| alert(oSelElem); |
| }, 300); |
| }); |
| } |
| </script> |
| <telerik:radeditor runat="server" ID="RadEditor1" OnClientLoad="OnClientLoad" StripFormattingOptions="NonesupressCleanMessage"> |
| </telerik:radeditor> |
| </div> |
| </form> |
| </body> |
| </html> |
