New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

AjaxSpellCheck Object

This article shows how to get a reference to the spellcheck object of RadEditor and lists its API.

The spellchecker object in RadEditor is based on RadSpell, but is an asyncronously created instance that integrates with the RadEditor UI and as such provides more limited functionality. It is only created when the spell check is invoked and otherwise it will be undefined. To manipulate its API you need to use a timeout before getting the reference, because otherwise the object will not be created yet.

How to get a reference to the AjaxSpellCheck object of RadEditor

ASP.NET
<telerik:RadEditor runat="server" ID="RadEditor1">
    <Content>
        miztake in showing how to invoke a spell check before saving
    </Content>
</telerik:RadEditor>
<asp:Button Text="save" OnClientClick="spellCheckAndSave(this); return false;" 
    ID="btnSave" OnClick="btnSave_Click" runat="server" />
<script>
    function spellCheckAndSave(btn) {
        btn.setAttribute("disabled", "disabled");
        //get a reference to the editor object
        var editor = $find("<%=RadEditor1.ClientID%>");
        //execute the spellcheck command
        editor.fire("AjaxSpellCheck");
        //use a timeout before getting the reference and using the control API
        setTimeout(function () {
            var spell = editor.get_ajaxSpellCheck();
            spell.add_spellCheckEnd(checkFinished);
        }, 10);
    }

    function checkFinished(sender, args) {
        __doPostBack("<%=btnSave.UniqueID%>", "");
    }
</script>

The AjaxSpellCheck object exposes the following public methods and properties to control its behavior:

AjaxSpellCheck Client-Side Methods

NameParametersReturn TypeDescription
addCustomWordStringAdds a custom word to the collection.The method takes the following arguments: word - The word to be added.
cancelSpellCheckBooleanStops the spell checking and retrieves the original state of the content.The method takes the following arguments: raiseEvent? - Indicates whether to raise the spellCheckEnd event.
finishSpellCheckBooleanStops the spell checking and updates the content.The method takes the following arguments: raiseEvent? - Indicates whether to raise the spellCheckEnd event.
get_editorTelerik.Web.UI.RadEditorReturns the RadEditor instance.
get_languageStringGets the language used by the Spell-Check service.
set_editorTelerik.Web.UI.RadEditorSets the RadEditor instance.The method takes the following arguments: editor - The RadEditor instance.
set_languageStringSets the language used by the Spell-Check service.The method takes the following arguments: language - The language.
spellCheckPerforms a spell check on the content.

AjaxSpellCheck Client-Side Methods for attaching/detaching client-side event handlers

NameArgumentsDescription
add_spellCheckEndFunctionAdds a handler for the spellCheckEnd AjaxSpellCheck client event.
add_spellCheckStartFunctionAdds a handler for the spellCheckStart AjaxSpellCheck client event.
remove_spellCheckEndFunctionRemoves a handler for the spellCheckEnd AjaxSpellCheck client event.
remove_spellCheckStartFunctionRemoves a handler for the spellCheckStart AjaxSpellCheck client event.
Not finding the help you need?
Contact Support