Setting OnClientCheckFinished in client?

2 posts, 0 answers
  1. Cheryl
    Cheryl avatar
    45 posts
    Member since:
    Jul 2006

    Posted 16 Oct 2013 Link to this post

    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?


  2. Marin Bratanov
    Marin Bratanov avatar
    3558 posts

    Posted 17 Oct 2013 Link to this post

    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: 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 %>");
        function firstFinished(sender, args)
            $get("logger").innerHTML = "first";
        function second()
            var spell = $find("<%=RadSpell1.ClientID %>");
            spell.set_controlToCheck("<%=Textbox2.ClientID %>");
        function secondFinished(sender, args)
            $get("logger").innerHTML = "second";
        function third()
            var spell = $find("<%=RadSpell1.ClientID %>");
            spell.set_controlToCheck("<%=Textbox3.ClientID %>");
        function thirdFinished(sender, args)
            $get("logger").innerHTML = "third";

    <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>

    Marin Bratanov
    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.
  3. DevCraft R3 2016 release webinar banner
Back to Top