Rad spell not triggering RadTextBoxChanged on a RadTextBox

2 posts, 1 answers
  1. p
    p avatar
    28 posts
    Member since:
    Sep 2008

    Posted 14 Dec 2009 Link to this post

    Hi,

    Rad spell is not triggering RadTextBoxChanged on  RadTextBox.
     I am using the updateDisplayValue on OnClientDialogClosed.
    Please let me know if you need more info.

    PS
  2. Answer
    Dimo
    Admin
    Dimo avatar
    8482 posts

    Posted 17 Dec 2009 Link to this post

    Hello,

    Browsers do not fire the "changed" event for textboxes, when their value is updated programmatically with Javasctript by using the textbox' value property. This is the reason why you need to call updateDisplayValue() explicitly after the spell check is finished.

    You can fire the event manually, but in this case you will not be able to cancel it via the event arguments. Instead, you will have the previous value at your disposal and set it back with textBoxInstance.set_value().


    <%@ Page Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls for ASP.NET AJAX</title>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadTextBox ID="RadTextBox1" runat="server">
        <ClientEvents OnValueChanged="MyValueChanged" />
    </telerik:RadTextBox>
     
    <telerik:RadSpell ID="RadSpell1" runat="server" ControlToCheck="RadTextBox1" ButtonText="SpellCheck"
        OnClientDialogClosed="MyClientDialogClosed" OnClientCheckStarted="MyClientCheckStarted" />
     
    <script type="text/javascript">
     
    var tbOldValue;
     
    function MyClientCheckStarted(sender, args)
    {
        var tb = $find("RadTextBox1");
        tbOldValue = tb.get_value();
    }
     
    function MyClientDialogClosed(sender, args)
    {
        var tb = $find("RadTextBox1");
        var tbNewValue = tb.get_value();
        tb.updateDisplayValue();
         
        if (tbNewValue != tbOldValue)
            tb.raise_valueChanged(tbNewValue, tbOldValue);
    }
     
    function MyValueChanged(sender, args)
    {
        alert("ValueChanged");
    }
     
    </script>
     
    </form>
    </body>
    </html>


    Greetings,
    Dimo
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top