RadSpell for ASP.NET

Client-Side Object Model Send comments on this topic.
See Also
Client Side Events and Configuration > Client-Side Object Model

Glossary Item Box

Configuration Properties

This property can be set in the server-side code as well.

Property

Description

DictionaryLanguage The name of the dictionary that will be used for the spellchecking.
ControlToCheck The ID of the control to be spellchecked when the ControlToSpellCheck property is not set in the ASPX declaration.

 

Methods

Method

Description

GetRadSpell(spellClientID) Use this method to obtain an instance of the client side RadSpell object. The spellClientID parameter is the ClientID property of the server control. Pass the ClientID like this:

var spell = GetRadSpell('<%= RadSpell1.ClientID %>');

GetDialogOpener() Returns the instance of the client-side DialogOpener object that handles that dialog opening/parameter passing processes.

spell.GetDialogOpener();

GetSelectedLanguage() Returns the currently selected DictionaryLanguage when the SupportedLanguages property is set.

spell.GetSelectedLanguage();

StartSpellCheck() Launch the spellcheck process:

spell.StartSpellCheck();

GetTextSource() Returns the reference to the instance of the TextSource object that RadSpell is attached to.
SetTextSource(source) Attaches a custom TextSource object to the RadSpell object.
IsSpellChecked() Returns true if the spellcheck process has completed (the OnClientCheckFinished event has been fired).

spell.IsSpellChecked();

SetSpellChecked(boolean) Sets whether the spellcheck process is completed (true) or not (false).

spell.SetSpellChecked(true);

Note: Should not be used directly. It is used by the spellcheck validator.
SpellCheck(source) Launch the spellcheck process for the provided TextSource.

spell.SpellCheck(spell.GetTextSource());



TextSource

 The TextSource is an object that you can spell-check using the Telerik RadSpell control. This object must implement two methods - one that gets the text to be spell-checked and another one that sets the modified text.  Telerik RadSpell comes with a default implementation -- HtmlElementTextSource, that can be used to access text from various HTML elements.

Methods

Method

Description

GetText() Returns the text to be spell-checked.
SetText(correctedText) Called by the RadSpell instance to set the corrected text back to the target control.

 

Example

The following example demonstrates how to:

  • Obtain a reference to the RadSpell object by using the static GetRadSpell function
  • Set the DictionaryLanguage property
  • Attach a custom TextSource to the RadSpell object
  • Start the spellchecking process by calling StartSpellCheck

 

<body>
    <script type="text/javascript">
    function MultipleTextboxSource(sources)
    {
        this._sources = sources;
        this.GetText=function()
        {
            var texts = [];
             for (var i = 0; i < this._sources.length; i++)
            {
                texts[texts.length] = this._sources[i].getText();
            }
             return texts.join("<controlSeparator><br/></controlSeparator>");
        }
        this.SetText = function(text)
        {
            var texts = text.split("<controlSeparator><br/></controlSeparator>");
             for (var i = 0; i < this._sources.length; i++)
            {
                this._sources[i].setText(texts[i]);
            }
        }
    }
    function StartSpellCheck()
    {
        var radSpell = GetRadSpell('<%=RadSpell1.ClientID %>');
        radSpell.SetTextSource(
                 new MultipleTextboxSource([
                     new HtmlElementTextSource(document.getElementById( 'TextBox1')),
                     new HtmlElementTextSource(document.getElementById( 'TextBox2')),
                     new HtmlElementTextSource(document.getElementById( 'TextBox3'))
                ]));
        radSpell.StartSpellCheck();
         return false;
    }
    function SetLanguage(e)
    {
        e = e || window.event;
        var target = e.target || e.srcElement;
        var radSpell = GetRadSpell('<%=RadSpell1.ClientID %>');
        radSpell.DictionaryLanguage = target.value;
    }
    </script>
    <form id="form1" runat="server">

        <asp:TextBox ID="TextBox1" runat="server">text1</asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server">text2</asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server">text3</asp:TextBox>

        <rad:RadSpell ID="RadSpell1" runat="server" DictionaryLanguage="en-US"
            ButtonType= "None" />
        <asp:Button ID="Button1" runat="server" Text="SpellCheck"
            OnClientClick= "return StartSpellCheck();"/>

        <asp:RadioButtonList ID="RadioButtonList1" runat="server">
            <asp:ListItem Text="English" Value="en-US" Selected="True"
                onclick= "SetLanguage()">
            </asp:ListItem>
            <asp:ListItem Text="German" Value="de-DE" onclick="SetLanguage()">
            </asp:ListItem>
            <asp:ListItem Text="French" Value="fr-FR" onclick="SetLanguage()">
            </asp:ListItem>
        </asp:RadioButtonList>

    
</body>

 

 

  See a live example at www.telerik.com

See Also