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

Editor Causes Ajax To Get Stuck In Loop

1 Answer 57 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Michel Laforce
Top achievements
Rank 1
Michel Laforce asked on 31 Oct 2011, 02:39 PM
Hi

the RadEditor is inside a AjaxUpdatedControl, I have the MaxTextLenght set and when it is exceeded, the message appears (the added text exceeded...), after the ajax loading panel appears but it gets stuck in an infinite loopthere. How can I stop this.

Thanks

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 31 Oct 2011, 03:29 PM
Hi Michel,

We are aware of this issue, but there is not a solution for this scenario.

Nevertheless, you can write your own validation mechanism similar to the following one:

Here is an example for multiple editors on the page:
 
<telerik:RadEditor ID="RadEditor1" runat="server" OnClientLoad="LimitCharacters"></telerik:RadEditor>
<telerik:RadEditor ID="RadEditor2" runat="server" OnClientLoad="LimitCharacters"></telerik:RadEditor>
<telerik:RadEditor ID="RadEditor3" runat="server" OnClientLoad="LimitCharacters"></telerik:RadEditor>
 
  <script type="text/javascript">
   
  var editorList = new Object();
  var editorLengthArray = [20,30,40];
  var counter = 0;
    
   
  function isAlphaNumericKey(keyCode)
  {
   if ((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91))
   {
    return true;
   }
   return false;
  }
   
  function LimitCharacters(editor)
  {       
   
      editorList[editor.get_id()] = editorLengthArray[counter];
      counter++;
       
      editor.attachEventHandler("onkeydown", function(e)
      {
        e = (e == null)? window.event : e;
        if (isAlphaNumericKey(e.keyCode))
        {  
            var maxTextLength = editorList[editor.get_id()];
                 
            textLength = editor.get_text().length;
            if (textLength >= maxTextLength)
            {
                alert('You are not able to type more than ' + maxTextLength + ' symbols!');
                e.returnValue = false;
            }
        }
       });
  }
  </script>
 
Just type in the content area to see the alert message.


or this provided with the Custom Validator in the following demo: Validator Support, e.g.

<telerik:radeditor runat="server" ID="RadEditor1"></telerik:radeditor>
 
<asp:CustomValidator runat="server" ID="CustomValidator1" ControlToValidate="RadEditor1" ClientValidationFunction="checkLength">* The text length should not exceed 50 symbols.</asp:CustomValidator> 
<script type="text/javascript"
    var limitNum = 50; 
        
    function checkLength(sender, args) 
    
        //Note that sender is NOT the RadEditor. sender is the <span> of the validator.
        //The content is contained in the args.Value variable    
        var editorText = args.Value;
        args.IsValid = editorText.length > limitNum; 
    
</script>



Best wishes,
Rumen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Editor
Asked by
Michel Laforce
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or