RadSpell for ASP.NET

Launching Upon Client-Side Events Send comments on this topic.
Tips and Tricks > Launching Upon Client-Side Events

Glossary Item Box

Problem

How to launch the spellchecker on various client-side events.

Solution

The spellchecker is started with a JavaScript function call on the client. It is easy to call this function from various client-side event handlers. For example, a TextBox control can be set to automatically check the spelling of its text once the user is finished typing and moves on to another control.

 

Follow the steps below to achieve this scenario:

1. We will assume that the TextBox control you want to check has ID of "TextBox1".

2. Set spellchecker's ButtonType property to "None". This will hide the default spellcheck button from the form:

<rad:radspell id="RadSpell1" runat="server" controltocheck="TextBox1" buttontype="None" />

3. Create a script block on your form that defines a JavaScript function, which will start the spellchecker:

<script language="javascript">
function spellCheck()
{
    var spell = GetRadSpell('<%= RadSpell1.ClientID %>');
    spell.StartSpellCheck();
}
</script>

4. Make the TextBox control's onBlur client-side handler call our spellCheck() function:

<asp:TextBox id="TextBox1" onblur="javascript: spellCheck();" runat="server">
this is a mistakr
</asp:TextBox>

This approach can be used not only for TextBoxes. You can use it to bind the spellchecker to any client-side event.