Getting Started with EJ 1 ASP.NET MVC SpellCheck
12 Sep 2017 / 2 minutes to read
This section explains briefly about how to create a SpellCheck Control in your application with ASP.NET MVC
Create your first SpellCheck in MVC
Create a ASP.NET MVC Project and add necessary assemblies, CSS and scripts with the help of the given MVC-Getting Started documentation. After creating this project, you can create a SpellCheck in following ways.
SpellCheck Using Helper element
In the view page, add SpellCheck helper as shown below.
Assign the service method (CheckWords) path reference to the property dictionaryUrl, which is mandatory to check the spelling of the word.
The CheckWords method will perform the splitting of target sentence into separate words and check each word is that an erroneous or not. If the word is erroneous fetching the possible suggestions for it and returns those details as a result.
@Html.EJ().SpellCheck("TextArea").DictionarySettings(dictionary => dictionary.CustomDictionaryUrl("../api/SpellCheck/AddToDictionary").DictionaryUrl("../api/SpellCheck/CheckWords"))
To spell check the content of the target element, you need to add one button and calling any one of the spell check method showInDialog or validate by clicking the button to highlight the error words.
The following code example depicts that checking the spelling of the target element through the showInDialog method.
Once you have completed the above steps, you will get an output like below.
To render the SpellCheck control, the following list of external dependencies are needed,
- jQuery - 1.7.1 and later versions
The other required internal dependencies are tabulated below,
Must be referred always first before using all the JS controls.
Used to handle data operation and should be used while binding data to JS controls.
spell check core script file.
Used to create our SpellCheck component with basic level HTML tag-like structure.
These files are referred for proper working of the sub-controls used within SpellCheck.
SpellCheck uses one or more sub-controls, therefore refer the
ej.web.all.min.js(which encapsulates all the
ejcontrols and frameworks in a single file) in the application instead of referring all the above specified internal dependencies.
To get the real appearance of the SpellChecker, the dependent CSS file
ej.web.all.min.css (which includes styles of all the widgets) should also needs to be referred.