Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in DotNetNuke > force spellchecking on submit--problem of editor.fire("AjaxSpellCheck");

Not answered force spellchecking on submit--problem of editor.fire("AjaxSpellCheck");

Feed from this thread
  • Luna avatar

    Posted on Dec 24, 2011 (permalink)

    version: RadSpell.NET2.dll  3.2.8.0    RadEditor.Net2.dll  7.3.6.0
    and no chance to upgrading

    I want to the function force spellchecking on submit, and
    found this:
    http://www.telerik.com/support/kb/aspnet-ajax/editor/enforce-spellchecking-on-submit.aspx

    when excute this: editor.fire("AjaxSpellCheck");
    firefox report the fire function not define.

    thank you very much!

    Reply

  • Rumen Rumen admin's avatar

    Posted on Dec 26, 2011 (permalink)

    Hello,

    You have found a KB article which applies to the RadEditor for ASP.NET AJAX and its spellchecker only.

    For your convenience I found the following help article meant for RadSpell Classic which is suitable for your scenario: Spellchecking Automatically Before Postback.

    Best regards,
    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

    Reply

  • Luna avatar

    Posted on Dec 26, 2011 (permalink)

    HI,
    thanks for you reply, because I still need the fucntion of bold and italic and show remain characters in editor on page, I could not use
    the method you provide, did you have other solution?
    and in my version ,have a bug:
    when use "OnClientLoad" , when load the page, will report a error;

    ---------------------------
    Message from webpage
    ---------------------------
    Exception while executing client event OnClientLoad Error:'LimitCharacters' is undefined
    ---------------------------
    OK  
    ---------------------------


    would you please help me again?
    thank you very much!!!!

    Reply

  • Rumen Rumen admin's avatar

    Posted on Dec 27, 2011 (permalink)

    Hello,

    You should put the Script above the RadEditor's declaration. For your convenience I have attached a sample working project which demonstrates the solution provided in the help article.

    Kind regards,
    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

    Reply

  • Luna avatar

    Posted on Dec 31, 2011 (permalink)

    hi:
    thanks very much for your reply, I still have some problem,
    when I use verifySpelling function, if click more times will report a error, please reference aaaaaa.jpg.
    and the counter is not correct, if input 1 character, the count of text still 0, if paste, it could not calutute the correct count, 
      would you please help me to point out the error of force spelling and  the correct remain character ??
    thank you very much and happy new year !!!!!

    <%@ Page Title="Home Page" Language="C#"  AutoEventWireup="true"
        CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register TagPrefix="radE" Namespace="Telerik.WebControls" Assembly="RadEditor.NET2" %>
    <%@ Register TagPrefix="radS" Namespace="Telerik.WebControls" Assembly="RadSpell.NET2" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head id="Head1" runat="server">
        <title></title>
      
    </head>
    <body>
      
    <script type="text/javascript">
        function checkSpelling() {
            var editor = $find("<%=RadEditor1.ClientID %>"); //get reference to RadEditor's instance  
            editor.fire("AjaxSpellCheck"); //execute the RadEditor's command "AjaxSpellCheck"  
            editor.add_spellCheckLoaded(function () {
                var spell = editor.get_ajaxSpellCheck();  //get a reference to RadEditor's SpellCheck  
                //save the content and submit the form when the spellchecker ends 
                spell.add_spellCheckEnd(function (sender, args) {
                    editor.saveContent(); //save the content before submission 
                    document.forms[0].submit(); //submit the form 
                });
            });
        
    </script>
      
      
      
    <script type="text/javascript">
      
        var spellCheckFinished = false;
        function verifySpelling() {
            if (spellCheckFinished == true)
                return;
      
            var spell = GetRadSpell('<%= RadSpell1.ClientID %>');
            spell.AttachEvent("OnClientCheckFinished", "checkFinished");
            spell.StartSpellCheck();
            return false;
        }
      
        function checkFinished(sender, args) {
            spellCheckFinished = true;
            args.SuppressCompleteMessage = true;
            setTimeout('MySubmit();', 100);
        }
      
        function MySubmit() {
            document.forms[0].submit();
        }
      
    </script>
    <script type="text/javascript">
        var maxTextLength = 20;
        var messageText = 'You are not able to type more than ' + maxTextLength + ' symbols!';
      
        function isAlphaNumericKey(keyCode) {
            if ((keyCode > 47 && keyCode < 58) || (keyCode > 64 && keyCode < 91) || (keyCode == 32)) {
                return true;
            }
            return false;
        }
      
        function LimitCharacters(editor) {
            editor.AttachEventHandler("onkeydown", function (e) {
                e = (e == null) ? window.event : e;
                textLength = editor.GetText().length;
                document.getElementById("counter").innerHTML = textLength;
      
                if (isAlphaNumericKey(e.keyCode)) {
                    textLength = editor.GetText().length;
                    document.getElementById("counter").innerHTML = textLength;
                    if (textLength >= maxTextLength) {
                        alert(messageText);
                        e.returnValue = false;
                        return false;
                    }
                }
            });
            editor.AttachEventHandler("onpaste", function (e) {
                var textLength = CalculateLength(editor);
                document.getElementById("counter").innerHTML = textLength;
                if (textLength >= maxTextLength) {
                    alert(messageText);
                    e.returnValue = false;
                    e.cancelBubble = true;
                    return false;
                }
            });
        }
      
        function CalculateLength(editor) {
            var textLength = editor.GetText().length;
            var clipboardLength = window.clipboardData.getData("Text").length;
            textLength += clipboardLength;
            return textLength;
        }
      
        function OnClientCommandExecuting(editor, commandName, oTool) {
            if (commandName == "PasteFromWord"
        || commandName == "PasteFromWordNoFontsNoSizes"
        || commandName == "PastePlainText"
        || commandName == "PasteAsHtml"
        || commandName == "Paste") {
                if (document.all) {
                    var textLength = CalculateLength(editor);
                    if (textLength >= maxTextLength) {
                        alert(messageText);
                        return false;
                    }
                }
            }
        }
    </script>
        <form id="form1" runat="server">
         <table width="700px" border="0px">
            <tr>
                <td colspan="2">
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" />
                </td>
            </tr>
            <tr>
                <td class="title" width="500px">
                  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="RadEditor1"
                        ErrorMessage="Message is required."
                        Display="Dynamic">*</asp:RequiredFieldValidator>
                    <asp:CustomValidator ID="CustomValidator2" runat="server" EnableClientScript="false"   
                         ErrorMessage="The message body should not be longer than the maxium number of characters."               
                          ControlToValidate="RadEditor1"  OnServerValidate="RadEditor1_Validate" Display="Dynamic" >*</asp:CustomValidator
                  Message:
                </td>
                <td  align="right">
                    <span id="counter"></span> Characters Left    
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <radE:RadEditor ID="RadEditor1" runat="server" ToolsFile="ToolsFile.xml"
                        SpellDictionaryLanguage="en-US" 
                        SpellCheckProvider="EditDistanceProvider" SpellEditDistance="2" 
                        ShowHtmlMode="false" ShowPreviewMode="false"                    
                        ShowSubmitCancelButtons ="false"
                        OnClientCommandExecuting="OnClientCommandExecuting"
                        OnClientLoad="LimitCharacters"
                        Skin="WebBlue" Height="200px" Width="700px">
                    </radE:RadEditor
                     <radS:RadSpell ID="RadSpell1" runat="server" ControlToCheck="RadEditor1"></radS:RadSpell>
                    <hr />
                </td>
            </tr>
            <tr>
                <td  colspan="2" align="right">
                    <asp:Button ID="btnCancel" runat="server" Text="Cancel"  CausesValidation="false" OnClick="btnCancel_Click"/>
                    <asp:Button ID="btnNext" runat="server" Text="Next" onclientclick="verifySpelling();return false;"  OnClick="btnNext_Click"/>
                </td>
            </tr>
        </table>
        </form>
    </body>
    </html>

    Reply

  • Luna avatar

    Posted on Dec 31, 2011 (permalink)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
      
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //for bug of could not show radeditor toolbar in firefox
            if (Request.Browser.Browser.ToLowerInvariant() == "firefox")
            {
                System.Reflection.FieldInfo browserCheckedField = typeof(Telerik.WebControls.RadEditor).GetField("_browserCapabilitiesRetrieved", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                browserCheckedField.SetValue(RadEditor1, true);
                System.Reflection.FieldInfo browserSupportedField = typeof(Telerik.WebControls.RadEditor).GetField("_isSupportedBrowser", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                browserSupportedField.SetValue(RadEditor1, true);
            }
        }
      
        #region btnNext Click
        protected void btnNext_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
      
            Response.Redirect("About.aspx");
        }
        #endregion
      
        #region btnCancel Click
        protected void btnCancel_Click(object sender, EventArgs e)
        {
        }
        #endregion
      
        protected void RadEditor1_Validate(object source, ServerValidateEventArgs args)
        {
            args.IsValid = true;
            string body = RadEditor1.Text;
            if (body.Length > 50)
            {
                args.IsValid = false;
            }
        
    }

    Reply

  • Luna avatar

    Posted on Dec 31, 2011 (permalink)





    <
    root>
        <modules>
            <module name="RadEditorStatistics" dockingZone="Top" enabled="false" visible="false" dockable="false" />
         </modules>
        <tools name="Toolbar1" dockable="false" enabled="true">
          <tool name="Bold" shortcut="CTRL+B" />
          <tool name="Italic" shortcut="CTRL+I" />
          <tool name="AjaxSpellCheck"/>
        </tools>
      
    </root>


    ToolsFile.xml
    Attached files

    Reply

  • Rumen Rumen admin's avatar

    Posted on Jan 3, 2012 (permalink)

    Hello,

    I believe that this sticky forum thread from RadSpell's section will be of help:
    Potentially Dangerous Request in ASP.NET 4

    As to the symbol counter: the paste control is allowed only by the IE browsers
    The RadEditorStatistics module is updated on selection change or when pressing the enter key to not decrease the editing performance in the content area. If you would like you can customize the module to be updated onkeyup event which will fix the issue. For your convenience I have attached the modified project.

    As to the onpaste event used in the demo it is supported by IE / FF only and will not work for the other browsers. Note that the Classic version of RadEditor does not also support the modern browsers.

    All the best,
    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

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > RadControls in DotNetNuke > force spellchecking on submit--problem of editor.fire("AjaxSpellCheck");