Dynamic Spell Checking

2 posts, 0 answers
  1. Matt Strickler
    Matt Strickler avatar
    1 posts
    Member since:
    Jan 2010

    Posted 08 Jan 2010 Link to this post

    This all works fine on the first click, it fixes all the typos for all available texboxes.

    When I click spellcheck a second time an error in the ScriptResource.axd where this.get_element() is null.  Any ideas what I can do to fix this problem. It seems to be my only hangup

    Web.Config:

          <add name="Telerik_Web_UI_DialogHandler_aspx" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" /> 
          <add name="Telerik_Web_UI_SpellCheckHandler_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" /> 
     

    MasterPage:

    <telerik:RadSpell ID="RadSpellControl" runat="server" ButtonType="None" SupportedLanguages="en-US,English" /> 
    <asp:Button ID="Button1" runat="server" Text="SpellCheck" OnClientClick="return StartSpellCheck();" 

    Javascript:

        <script type="text/javascript"
            function MultipleTextboxSource(sources) { 
                this._sources = sources; 
                this.get_text = function() { 
                    var texts = []; 
                    for (var i = 0; i < this._sources.length; i++) { 
                        texts[texts.length] = this._sources[i].get_text(); 
                    } 
                    return texts.join("<controlSeparator><br/></controlSeparator>"); 
                } 
                this.set_text = function(text) { 
                    var texttexts = text.split("<controlSeparator><br/></controlSeparator>"); 
                    for (var i = 0; i < this._sources.length; i++) { 
                        this._sources[i].set_text(texts[i]); 
                    } 
                } 
            } 
            function StartSpellCheck() { 
             
                var radSpell = $find('ctl00_ctl00_RadSpellControl'); 
                var textboxes = $(':text'); 
                var HtmlElementSources = []; 
                for (var i = 0; i < textboxes.length; i++) { 
                    HtmlElementSources[i] = new Telerik.Web.UI.Spell.HtmlElementTextSource($get(textboxes[i].id)); 
                } 
                radSpell.set_textSource(new MultipleTextboxSource(HtmlElementSources)); 
                radSpell.startSpellCheck(); 
                return false; 
            } 
            function SetLanguage(e) { 
                ee = e || window.event; 
                var target = e.target || e.srcElement; 
                var radSpell = GetRadSpell('ctl00_ctl00_RadSpell1'); 
                radSpell.DictionaryLanguage = target.value; 
            } 
        </script> 

    Error (on line 93, this.get_element() is null)

    87 this.set_element({value:""}) 
    88 }else{if(b.nodeName=="IFRAME"&&b.contentWindow!=null {this.set_element(b.contentWindow.document.body) 
    89 }}b=null 
    90 },dispose:function(){this._element=null
    91 Telerik.Web.UI.Spell.HtmlElementTextSource.callBaseMethod(this,"dispose") 
    92 },get_text:function(){var d=""; this.get_element() is null 
    93 if(this.get_element().value!=null){try{d=this.get_element().value 
    94 }catch(c){alert("Error getting text from control.\n"+c.message) 
    95 }}else{if(this.get_element().innerHTML!=null {try{d=this.get_element().innerHTML 
    96 }catch(c){alert("Error getting HTML from the control.\n"+c.message) 
    97 }}else{alert("No value or innerHTML attribute. Cannot access text.") 
    98 }}return d  



  2. Rumen
    Admin
    Rumen avatar
    12849 posts

    Posted 08 Jan 2010 Link to this post

    Hi Matt,

    The error is caused by that some of the textboxes does not exist in the moment of spellchecking.
    RadSpell does not automatically check whether the textbox really exists before the spellchecking and if this element is removed for some reason then the spellcheck will throw the reported error.

    To fix the problem, you should check whether the element that will be spellchecked really exist and after that spellcheck it.


    Sincerely yours,
    Rumen
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top