How to use NetSpell???

Last post 11-19-2008, 9:24 PM by Adam. 3 replies.
Sort Posts: Previous Next
  •  11-12-2008, 1:08 PM 45655

    How to use NetSpell???

    I'm trying to integrate NetSpell into my app such that when I click the Submit button on the page I spell-check the contents of an ASP.Net TextBox and the CuteEdit XHTML. I've tried poring through the demos, NetSpell docs, etc and I can't find anything comprehensive on how to implement NetSpell beyond the built-in integration with CuteEdit.
     
    Can you provide some guidance? I tried to attach my Default.aspx and the C# code-behind but it won't let me. I have the spellcheck.aspx, spell.cs and spell.css files in my project, the NetSpell DLL and dictionary file in my Bin folder.
     
    When the page posts back it seems to run everything but I always end up in the MisspelledWord event handler. How do I get NetSpell to suggest words? Do I have to handle replacing the actual word in the text?  I need some comprehensive guide to implementing this component in a .Net 2.0 app.
     
    I need to demonstrate this combination of products works or my management won't buy CuteEdit.
     
    Since I can't upload files, here is the source for my page and code-behind:
     

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="BMailV2Edit._Default" %>
    <%@ Register Assembly="CuteEditor" Namespace="CuteEditor" TagPrefix="CE" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
              <asp:TextBox ID="textbox1" runat="server" Text="Put som textt heree" />
            </div>
            <div>
                <ce:editor ID="editor1" runat="server" UseRelativeLinks="false"
                    StyleWithCSS="true" URLType="Absolute"
                    ConfigurationPath="~/CuteSoft_Client/CuteEditor/Configuration/HIG.config"
                    >
                    <FrameStyle BackColor="White" BorderColor="#DDDDDD" BorderWidth="1px" BorderStyle="Solid" Height="100%" Width="100%"></FrameStyle>
                </ce:editor>
                <br /> 
            </div>
                <div>
                <asp:Button ID="Submit1" runat="server" Text="Show Page"
                    onclick="Submit1_Click" />
            </div>
            <div>
                <br />
                <br />
                <asp:Literal id="Output" runat="server"></asp:Literal>
            </div>
        </form>
    </body>
    </html>
     

    using System;
    using System.IO;
    using NetSpell.SpellChecker.Dictionary;

    namespace BMailV2Edit
    {
        public partial class _Default : System.Web.UI.Page
        {

            // instantiate spellchecker
            NetSpell.SpellChecker.Spelling SpellChecker = new NetSpell.SpellChecker.Spelling();
            NetSpell.SpellChecker.Dictionary.WordDictionary WordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary();

            protected void Page_Load(object sender, EventArgs e)
            {
                editor1.Setting["security:ImageGalleryPath"] = "~/Graphics";
                editor1.Setting["security:TemplateGalleryPath"] = "~/Templates";

                // get dictionary from cache
                // if not in cache, create new
                WordDictionary = new NetSpell.SpellChecker.Dictionary.WordDictionary();
                WordDictionary.EnableUserFile = false;
                string folderName;

                if (Request.ServerVariables["SERVER_NAME"].ToString() == "localhost")
                {
                    folderName = "bin\\";
                }
                else
                {
                    folderName = "e:\\web\\cuteedit\\bin\\";
                }

                folderName = this.MapPath(Path.Combine(Request.ApplicationPath, folderName));
                WordDictionary.DictionaryFolder = folderName;

                //load and initialize the dictionary
                WordDictionary.Initialize();

                SpellChecker.Dictionary = WordDictionary;
                SpellChecker.SuggestionMode =  NetSpell.SpellChecker.Spelling.SuggestionEnum.PhoneticNearMiss;
                // add event handlers

                SpellChecker.MisspelledWord +=
                    new NetSpell.SpellChecker.Spelling.MisspelledWordEventHandler(SpellChecker_MisspelledWord);

                SpellChecker.ReplacementWord +=
                    new NetSpell.SpellChecker.Spelling.ReplacedWordEventHandler(SpellChecker_ReplacedWord);

                SpellChecker.EndOfText +=
                    new NetSpell.SpellChecker.Spelling.EndOfTextEventHandler(SpellChecker_EndOfText);

                SpellChecker.DoubledWord +=
                    new NetSpell.SpellChecker.Spelling.DoubledWordEventHandler(SpellChecker_DoubledWord);

            }

            protected void Submit1_Click(object sender, EventArgs e)
            {
                editor1.CleanUpMicrosoftWordHTML();
                editor1.CleanUpHTMLCode();

                // Start Spell Checking
               
                SpellChecker.Text = textbox1.Text;
                Session["spellfield"] = "textbox1";
                SpellChecker.SpellCheck();

                // Start Spell Checking
                SpellChecker.Text = editor1.XHTML;
                Session["spellfield"] = "editor1";
                SpellChecker.SpellCheck();
               
                string XHTML="<HTML><BODY>"+editor1.XHTML+ "</BODY></HTML>";
                Output.Text = "<h3>Output</h3><div class=\"CodeBlock\">" + XHTML + "</div>" +
                    "<h3>HTML</h3><div class=\"CodeBlock\">" + Server.HtmlEncode(XHTML).Replace("\n", "<br>") + "</div>";

            }

            private void SpellChecker_DoubledWord(object sender,
                                          NetSpell.SpellChecker.SpellingEventArgs args)
            {
                // update text
                if (Session["spellfield"].ToString() == "textbox1")
                {
                    textbox1.Text = SpellChecker.Text;
                }
                else
                {
                    editor1.XHTML = this.SpellChecker.Text;
                }
            }

            private void SpellChecker_EndOfText(object sender,
                                                System.EventArgs args)
            {
                // update text
                if (Session["spellfield"].ToString() == "textbox1")
                {
                    textbox1.Text = this.SpellChecker.Text;
                }
                else
                {
                    editor1.XHTML = this.SpellChecker.Text;
                }
            }

            private void SpellChecker_MisspelledWord(object sender,
                                                     NetSpell.SpellChecker.SpellingEventArgs args)
            {

                if (Session["spellfield"].ToString() == "textbox1")
                {
                    int i = args.TextIndex;
                    string j = args.Word;
                    int k = args.WordIndex;
                    textbox1.Text = this.SpellChecker.Text;
                }
                else
                {
                    editor1.XHTML = this.SpellChecker.Text;
                }
            }

            private void SpellChecker_ReplacedWord(object sender,
                                                 NetSpell.SpellChecker.ReplaceWordEventArgs args)
            {
                int i = args.TextIndex;
                string j = args.Word;
                int k = args.WordIndex;
                string l = args.ReplacementWord;
                textbox1.Text = this.SpellChecker.Text;
            }
         }
    }

     
  •  11-17-2008, 9:07 AM 45866 in reply to 45655

    Re: How to use NetSpell???

    Nobody has ever integrated NetSpell on either the server or client side to spell-check multiple controls including a CuteEditor control? Really?
     
  •  11-17-2008, 2:44 PM 45883 in reply to 45655

    Re: How to use NetSpell???

  •  11-19-2008, 9:24 PM 45973 in reply to 45655

    Re: How to use NetSpell???

    1. Please download the control again:

      http://cutesoft.net/download/cuteeditor_for_net6.zip

    2. Demo:

      http://richtextbox.com/test/netspell.aspx
    3. Code:

      <textarea id="txtMessage" name="txtSummary" rows="8" wrap="VIRTUAL" cols="45"></textarea>

      <input id="btnSpellMessage" onclick="checkSpellingById('txtSummary','/CuteSoft_Client/CuteEditor/SpellCheck.aspx')" type="button" value="Spell Check" name="btnSpellCheckMessage" />


    Hope it helps.  


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

View as RSS news feed in XML