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

Dynamic Spell Checking

1 Answer 92 Views
Spell
This is a migrated thread and some comments may be shown as answers.
Matt Strickler
Top achievements
Rank 1
Matt Strickler asked on 08 Jan 2010, 01:09 PM
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  



1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 08 Jan 2010, 03:39 PM
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.
Tags
Spell
Asked by
Matt Strickler
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or