Jscript Spell Checker in MVC 5

Hi,
I am using the JavaScript Spellcheck in my mvc5 project.
My cshtml code snippet.
<script type="text/javascript">
    $("#TextArea").ejSpellCheck({
        dictionarySettings: {
            dictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/CheckWords",
            customDictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/AddToDictionary"
        }
    });
    $("#SpellCheck").ejButton({ width: "200px", height: "25px", click: "showInContextMenu", text: "Spell check" });


    function showInContextMenu() {
        var spellObj = $("#TextArea").data("ejSpellCheck");
        spellObj.validate();
    }
.
Everything is working fine as long ss i use (dictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/CheckWords")
But i need to use a custom dictionary located in my App_Data Directory.
I need to use something like this ("dictionaryUrl: "~/App_Data/Custom.dic"
Can you please give me an example code how to do it.
Thank you

6 Replies

GE George replied to George February 24, 2020 09:33 AM UTC

Hi,
I am using the JavaScript Spellcheck in my mvc5 project.
My cshtml code snippet.
<script type="text/javascript">
    $("#TextArea").ejSpellCheck({
        dictionarySettings: {
            dictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/CheckWords",
            customDictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/AddToDictionary"
        }
    });
    $("#SpellCheck").ejButton({ width: "200px", height: "25px", click: "showInContextMenu", text: "Spell check" });


    function showInContextMenu() {
        var spellObj = $("#TextArea").data("ejSpellCheck");
        spellObj.validate();
    }
.
Everything is working fine as long ss i use (dictionaryUrl: "http://js.syncfusion.com/demos/ejservices/api/SpellCheck/CheckWords")
But i need to use a custom dictionary located in my App_Data Directory.
I need to use something like this ("dictionaryUrl: "~/App_Data/Custom.dic"
Can you please give me an example code how to do it.
Thank you

Hi,
Also I need  you to give me instructions on what nuget packages to use.
I am confused.
There are several packages available like Syncfusion.AspNet.MVC5,syncfusion.EJ2.MVC5,Syncfusion.EJ2.SpellChecker.AspNet.Mvc5
Thank you


MK Muthukrishnan Kandasamy Syncfusion Team February 24, 2020 11:25 AM UTC

Hi George, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your query in EJ SpellCheck control. you can use custom dictionary in your project. We have prepared KB documentation for using SpellCheck control in MVC project. please refer to the below link for KB documentation. 
 
 
For EJ1 SpellCheck control you need to install Syncfusion.AspNet.MVC5 NuGet package. 
 
Refer the below documentation link to know more about SpellCheck in MVC. 
 
Please let us know, if you need any assistance. 
 
Regards, 
Muthukrishnan K


GE George February 24, 2020 02:18 PM UTC

Hi,
Thank you for your time.
I have already checked both links.
Regarding the first link 
On code
  1. [AcceptVerbs("Get", "Post")]
  2.         [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
  3.         public object AddToDictionary(string callback, string data)
  4.         {
  5.             var serializer = new JavaScriptSerializer();
  6.             Actions args = (Actions)serializer.Deserialize(data, typeof(Actions));
  7.             if (args.CustomWord != null)
  8.             {
  9.                 this.AddToCustomDictionary(args.CustomWord); // add custom words
  10.             }
  11.             HttpContext.Current.Response.Write(string.Format("{0}({1});", callback, serializer.Serialize(args.CustomWord)));
  12.             return string.Empty;
  13.         }
  14. i get the error that "Actions does not contain a definition for CustomWord,RequestType,Model,ErrorWord
  15. There is definitely something missing with the 'Actions'.
               Also List<Status> could not be found.

Regarding the second link
I realy dont know what to do.I see only some controller code.
Beside all that SyncfusionSpellChecker.Base is unlisted on Nuget.org
Can you maybe help me out by providing me with sample code ?
Thank you



MK Muthukrishnan Kandasamy Syncfusion Team February 25, 2020 04:26 PM UTC

Hi George, 
  
Thanks for the update. 
  
Query 1: i get the error that "Actions does not contain a definition for CustomWord, RequestType, Model,ErrorWord 
  
This actions parameter was added in the Models file of the project. Refer the below code block. 
  
[SpellModel.cs] 
    public class Actions 
    { 
        public string Text { get; set; } 
        public string CustomWord { get; set; } 
        public SpellModel Model { get; set; } 
        public string RequestType { get; set; } 
        public string ErrorWord { get; set; } 
    } 
  
  
Query 2: Can you maybe help me out by providing me with sample code ? 
  
In the previous update we have shared kb documentation link which also contains the ASP.NET MVC sample project with SpellCheck control. 
  
Please refer the below link for the sample. 
  
  
  
Query 3: Beside all that SyncfusionSpellChecker.Base is unlisted on Nuget.org 
  
You can get Syncfusion.SpellChecker.Base dll in below location. Please find it below.  
  
C:\Program Files (x86)\Syncfusion\Essential Studio\{Product Version}\Assemblies\Based on your Assembly version\  
  
(e.g)  C:\Program Files (x86)\Syncfusion\Essential Studio\15.4.0.17\Assemblies\4.5\Syncfusion.SpellChecker.Base.dll  
  
Or otherwise, you can follow the below help document to install the spell checker package in your application.  
  
  
  
Please let us know, if you need any assistance on this. 
  
Regards, 
Muthukrishnan K 



GE George February 29, 2020 09:24 AM UTC

Hi,
Thank you for your effort to help me.
I finally managed to making it work BUT i have an issue.
Its working only with English Dictionary.
When i try to use a dictionary of another Language(non Latin) for example Greek,
spellchecking is not working.
Is this a known issue ?

Thank you

Update:
First i corrected the "Regex.Replace" in GetStatus() and now i am getting the errorWords correct.(Latin and non-Latin words)
I thought that this would be the solution.
But  on my page only the Latin words are shown with the red underline.
Still not able to work with non-Latin words.


MK Muthukrishnan Kandasamy Syncfusion Team March 3, 2020 07:21 AM UTC

 
Thanks for the update. 
 
We don’t have built-in support to configure spell check for other languages, since we haven’t licensed dictionary files for other languages. But you can customize this by referring the dictionary file for their language in the path configured in the server-side controller method. It works based on the given dictionary files also works on only one language at a time. This is our EJ SpellCheck control behavior. If you are customized to work on Latin words, then it will not check the non-Latin words.  
We have used RegEx to identify whether the word is English or not. To work with other languages, you also need to change the Regex based on your requirements. 
 
Please let us know, if you need any assistance. 
 
Regards, 
Muthukrishnan K 


Loader.
Up arrow icon