Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Spell > Catching 'onChange' event
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Catching 'onChange' event

Feed from this thread
  • Tracey Van Niekerk avatar

    Posted on Oct 25, 2005 (permalink)

    Hi,
    Was hoping someone could give me some advice on how to go about detecting / catching when text has changed in a textbox due to the spellcheck being performed.

    I have an server control type textbox (asp:textbox) which has a onChange javascript event which is fired. However when I perform the spellcheck function and text is altered via the spell checker this event is not fired and therefore is not saved due to this onChange event not being run.

    Any suggestions on how I could go about getting this event to fire off?
    Many thanks
    Tracey

  • Hristo Deshev Hristo Deshev admin's avatar

    Posted on Oct 25, 2005 (permalink)

    Hi Tracey,

    You can define your own text source object and call the onchange event handler when the text is sent back to the source.  Of course, you should wrap the textbox, so that the source gets and sets the text.  Here is an example with a multiline textbox:

    <asp:TextBox ID="textBox1" onchange="OnTextAreaChange()" Runat="server" Rows="5" Columns="50" TextMode="MultiLine" cssClass="">Thisz is a server side TextBox with some delibirate mistakees.</asp:TextBox>

    <radS:RadSpell ID="spell1" Runat="server" ControlToCheck="textBox1" ButtonLabel=">> Spellcheck with a Link Button" ButtonType="LinkButton"  />

    <script type="text/javascript">
    function OnTextAreaChange()
    {
        alert("Text changed");
    }

    var textAreaSource =
    {
        textArea : document.getElementById("<%= textBox1.ClientID%>"),
        getText : function()
        {
            return this.textArea.value;
        },
       
        setText: function(text)
        {
            this.textArea.value = text;
            var self = this;
            window.setTimeout(function(){self.textArea.onchange();}, 200);
        }
    };

    var spellChecker = RadSpell.getSpellChecker("<%= spell1.ClientID%>");
    spellChecker.setTextSource(textAreaSource);
    </script>


    Note the self.textArea.onchange() call in the setText method.  It will fire your event handler.

    Sincerely yours,

    Hristo Deshev
    the telerik team

  • Tracey Van Niekerk avatar

    Posted on Oct 25, 2005 (permalink)

    Thanks for that bit of code - With a bit of tweaking of my section I was able to get the onChange event to fire.

    Regards
    Tracey

  • Mark Meir avatar

    Posted on Mar 12, 2007 (permalink)

    Hi there,

    Is this still the only way to get the onchange event to fire when text is replaced by the spell checker?  It doesn't appear to be firing for me.

    Thanks,

    Wes

  • Tsvetie Tsvetie admin's avatar

    Posted on Mar 12, 2007 (permalink)

    Hi Mark,
    Please use the following code:

    <asp:TextBox ID="textBox1" onchange="OnTextAreaChange()" Runat="server" Rows="5" Columns="50" TextMode="MultiLine" cssClass="">Thisz is a server side TextBox with some delibirate mistakees.</asp:TextBox> 
     
    <radS:RadSpell ID="spell1" Runat="server" ControlToCheck="textBox1" ButtonLabel=">> Spellcheck with a Link Button" ButtonType="LinkButton"  /> 
     
    <script type="text/javascript">  
    function OnTextAreaChange()  
    {  
        alert("Text changed");  
    }  
     
    var textAreaSource =   
    {  
        textArea : document.getElementById("<%= textBox1.ClientID%>"),  
        GetText : function()  
        {  
            return this.textArea.value;  
        },  
          
        SetText: function(text)  
        {  
            this.textArea.value = text;  
            var self = this;  
            window.setTimeout(function(){self.textArea.onchange();}, 200);  
        }  
    };  
     
    var spellChecker = GetRadSpell("<%= spell1.ClientID%>");  
    spellChecker.SetTextSource(textAreaSource);  
    </script> 


    Greetings,
    Tsvetie
    the telerik team

  • Mark Meir avatar

    Posted on Mar 12, 2007 (permalink)

    I have a textbox inside a datalist control.  I would need to "attach" this code to each item in the list as the textbox is rendered, for this to work.  Why doesn't the control call the OnChange event of the control it is validating?  That would seem to be the logically route to take.

    If this is the only method of getting the OnChange event to fire for textboxes that have their text changed via r.a.d.spell then I'm not sure this will work for us.

    Any other solutions?

    Thanks,

    WES

  • Tsvetie Tsvetie admin's avatar

    Posted on Mar 14, 2007 (permalink)

    Hello Mark,
    The OnChange event of the TextBox is not fired automatically and the current version of the r.a.d.spell does not fire this event. You are the first to mention such functionality and I forwarded the idea to our developers for consideration. For the time being, the proposed approach is the easiest way to achieve the described functionality.

    Best wishes,
    Tsvetie
    the telerik team

  • Mark Meir avatar

    Posted on Mar 14, 2007 (permalink)

    Well unfortunately the propsed solution will not work for us.  I guess we'll have to wait and see if the next version has a better solution.

    Wes

  • Tsvetie Tsvetie admin's avatar

    Posted on Mar 14, 2007 (permalink)

    Hi Mark,
    If you agree to provide us with detailed information on the reason why you need this event to fire and what was the original scenario that made you look for such an option, we will gladly advise you if there is a way to achieve what you are after with the current version of the control. If you agree to this, it would be best to open a new support thread and send us a simple project, with which we can work on the possible solutions.

    Sincerely yours,
    Tsvetie
    the telerik team

  • Milind Raje avatar

    Posted on Aug 11, 2010 (permalink)

    I have multiple text boxes in a data repeater. How do I associate all the text boxes to a single RadSpell? The problem is I am unable to assign the "controlsToCheck" property. I do not want multiple spell check control for each item in the repeater.
    Thanks
    milind

  • Rumen Rumen admin's avatar

    Posted on Aug 13, 2010 (permalink)

    Hi Milind,

    In order to check more than one control, you should set only the ControlsToCheck property and separate the control IDs with commas. For your convenience I have attached a sample page with single instance of RadSpell configured to spell check two RadTextBoxes controls placed in FormTemplate of RadGrid.


    Sincerely yours,
    Rumen
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
    Attached files

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Spell > Catching 'onChange' event