NetSpell Integration - Trigger Spell Check Externally

Last post 08-31-2010, 9:29 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  02-05-2010, 1:35 PM 58552

    NetSpell Integration - Trigger Spell Check Externally

    We're trying to integrate CuteEditor with the standard NetSpell code. What I've done is renamed all the functions from the basic spell.js I downloaded from the NetSpell project, and added the SpellCheck.aspx to the project. The independent NetSpell install works on everything just fine, but when it hits a CuteEditor TextArea the data isn't correct. 
     
    CuteEditor's spell check currently functions just fine, but we're trying to allow the users to spell check everything on the page with the click of one button. So, I've been trying to trigger the CuteEditor internal SpellCheck functionality by creating a special case for the CuteEditor text areas, which all have CuteEditor in their ID since I've named them as such. Unfortunately, I don't have the clientID of each editor as we're creating them dynamically. Whenever this code hits a CuteEditor text area and calls ExecCommand, it fails because the method doesnn't exist. Is there anything I can do to trigger the spell check functionality using the ID of the textarea?
     
    JavaScript for the checkSpelling() function is below:
    1. function NScheckSpelling()   
    2. {   
    3.     NScheckElements = new Array();   
    4.     //loop through all tag groups   
    5.     for (var i = 0; i < NStagGroup.length; i++)   
    6.     {   
    7.         var sTagName = NStagGroup[i];   
    8.         var oElements = document.getElementsByTagName(sTagName);   
    9.         //loop through all elements   
    10.         for(var x = 0; x < oElements.length; x++)   
    11.         {   
    12.             if (oElements[x].id.indexOf("CuteEditor") != -1){   
    13.                 var editor1 = document.getElementById(oElements[x].id);   
    14.                 try{   
    15.                     editor1.ExecCommand("netspell");   
    16.                 }   
    17.                 catch(e){   
    18.                     alert("Error for CE: " + oElements[x].id + " -- Exception: " + e.description)   
    19.                 }                   
    20.             }   
    21.             else{   
    22.                 if ((sTagName == "INPUT" && oElements[x].type == "text") || sTagName == "TEXTAREA"){   
    23.                     NScheckElements[NScheckElements.length] = oElements[x].id;   
    24.                 }                   
    25.                 else if ((sTagName == "DIV" || sTagName == "SPAN") && oElements[x].isContentEditable){   
    26.                     NScheckElements[NScheckElements.length] = oElements[x].id;                   
    27.                 }                   
    28.             }               
    29.         }   
    30.     }   
    31.     NSopenSpellChecker();   
    32. }  
    Thanks,
    William
    Filed under:
  •  02-15-2010, 10:36 AM 58704 in reply to 58552

    Re: NetSpell Integration - Trigger Spell Check Externally

    If it can't be done, that's okay. I just need to know. :)
  •  08-31-2010, 7:45 PM 63766 in reply to 58704

    Re: NetSpell Integration - Trigger Spell Check Externally

    No idea whether it can be done or not but in another post Adam said to refer to the field like this:
     
    Please use:
     
    var editor1 = document.getElementById('<% = Editor1.ClientID%>');
     
    instead of
     
    var editor1 = document.getElementById('CE_Editor1_ID');
     

    Hope that helps

  •  08-31-2010, 9:29 PM 63769 in reply to 58704

    Re: NetSpell Integration - Trigger Spell Check Externally

    Hi abyssknight,
     
    How to get the clientId of editors which created dynamically.
     
    1. <%@ Page Language="C#" %>   
    2.   
    3. <%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>   
    4. <html>   
    5. <head>   
    6.     <title>example</title>   
    7. </head>   
    8. <body>   
    9.     <form id="Form1" runat="server">   
    10.         <h4>   
    11.             How many Editors would you like to create? (<i>Please choose vaule between 1 and 10</i>)</h4>   
    12.         <asp:TextBox runat="Server" ID="txtTBCount" Columns="3" /><br />   
    13.         <br />   
    14.         <asp:Button runat="server" Text="Create Editors" OnClick="CreateEditors" ID="Button1" />   
    15.         <input type="button" value="Show all editor client id" onclick="showAllEditorId()" />   
    16.         <asp:PlaceHolder runat="server" ID="EditorsHere" />   
    17.         <asp:HiddenField ID="idList" runat="server" />   
    18.     </form>   
    19. </body>   
    20. </html>   
    21.   
    22. <script runat="server">      
    23.     int count = 1;   
    24.   
    25.     void IterateThroughChildren(Control parent)   
    26.     {   
    27.         foreach (Control c in parent.Controls)   
    28.         {   
    29.             if (c.GetType().ToString().Equals("CuteEditor.Editor") &&   
    30.                 c.ID == null)   
    31.             {   
    32.                 ((CuteEditor.Editor)c).Text ="my clientId is: "+ c.ClientID;   
    33.                 ((CuteEditor.Editor)c).AutoConfigure = AutoConfigure.Simple;   
    34.                 ((CuteEditor.Editor)c).Height = 200;   
    35.                 ((CuteEditor.Editor)c).ThemeType = ThemeType.OfficeXP;   
    36.                 idList.Value += c.ClientID;   
    37.                 idList.Value += "-------";   
    38.                 count++;   
    39.             }   
    40.   
    41.             if (c.Controls.Count > 0)   
    42.             {   
    43.                 IterateThroughChildren(c);   
    44.             }   
    45.         }   
    46.     }   
    47.   
    48.     void CreateEditors(Object sender, EventArgs e)   
    49.     {   
    50.   
    51.         int n = Int32.Parse(txtTBCount.Text);   
    52.   
    53.         // now, create n Editors, adding them to the PlaceHolder EditorsHere   
    54.         for (int i = 0; i < n; i++)   
    55.         {   
    56.             EditorsHere.Controls.Add(new CuteEditor.Editor());   
    57.         }   
    58.   
    59.         // now, set the Text property of each CuteEditor.Editor   
    60.         IterateThroughChildren(this);   
    61.     }   
    62. </script>   
    63.   
    64. <script>   
    65.   
    66. function showAllEditorId()   
    67. {   
    68.     var idList=document.getElementById("<%= idList.ClientID %>");   
    69.     alert(idList.value);   
    70. }   
    71. </script>  
    Regards,
     
    Ken
View as RSS news feed in XML