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

Setting OnClientCheckFinished in client?

1 Answer 7 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Cheryl
Top achievements
Rank 1
Cheryl asked on 17 Oct 2013, 02:40 AM
Is there a way to set the OnClientCheckFinished method in the client?

I want to reuse the same javascript and single radspell control if I can.

I have 3 buttons.

Each button can go through the same code to run the spellcheck (the same control is being checked each time), but after completing I want them to do different things.

Is this possible or will I need to duplicate my code?

Thanks

Cheryl

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 Oct 2013, 01:27 PM
Hi Cheryl,

You can use the client-side API of the control to dynamically add and remove event handlers, as well as set a dynamic control to be checked: http://www.telerik.com/help/aspnet-ajax/spell-client-side-api.html. If ind it easier to just add a spell control for each textbox and assign the desired handler in its markup, yet here is an example of working with one and dynamic events. You can, of course, further refactor this to match your needs:
<script type="text/javascript">
    function first()
    {
        var spell = $find("<%=RadSpell1.ClientID %>");
        spell.set_controlToCheck("<%=Textbox1.ClientID %>");
        spell.add_clientCheckFinished(firstFinished);
        spell.startSpellCheck();
    }
    function firstFinished(sender, args)
    {
        sender.remove_clientCheckFinished(firstFinished);
        $get("logger").innerHTML = "first";
    }
 
    function second()
    {
        var spell = $find("<%=RadSpell1.ClientID %>");
        spell.set_controlToCheck("<%=Textbox2.ClientID %>");
        spell.add_clientCheckFinished(secondFinished);
        spell.startSpellCheck();
    }
    function secondFinished(sender, args)
    {
        sender.remove_clientCheckFinished(secondFinished);
        $get("logger").innerHTML = "second";
    }
 
    function third()
    {
        var spell = $find("<%=RadSpell1.ClientID %>");
        spell.set_controlToCheck("<%=Textbox3.ClientID %>");
        spell.add_clientCheckFinished(thirdFinished);
        spell.startSpellCheck();
    }
    function thirdFinished(sender, args)
    {
        sender.remove_clientCheckFinished(thirdFinished);
        $get("logger").innerHTML = "third";
    }
</script>

<asp:TextBox ID="Textbox1" runat="server" Text="firrst" />
 
<asp:TextBox ID="Textbox2" runat="server" Text="seconnd" />
 
<asp:TextBox ID="Textbox3" runat="server" Text="thirrd" />
 
<telerik:RadSpell ID="RadSpell1" runat="server" ButtonType="None" />
 
<asp:Button ID="Button1" Text="check first" OnClientClick="first(); return false;" runat="server" />
<asp:Button ID="Button2" Text="check second" OnClientClick="second(); return false;" runat="server" />
<asp:Button ID="Button3" Text="check third" OnClientClick="third(); return false;" runat="server" />
 
<span id="logger"></span>



Regards,
Marin Bratanov
Telerik
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 the blog feed now.
Tags
Spell
Asked by
Cheryl
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or