Skip to main content

Spell Checker

  • 2 minutes to read

Spell Checker is a non-visual extension used to check the spelling of text contained in text editing controls.

To learn more about Spell Checker and see it in action, refer to its online demos.

#Implementation Details

Spell Checker is represented by the SpellCheckerExtension class. Its instance can be accessed via the ExtensionsFactory.SpellChecker helper method, which is used to add a Spell Checker extension to a view. This method’s parameter provides access to the Spell Checker settings implemented by the SpellCheckerSettings class, allowing you to fully customize the extension.

#Declaration

Spell Checker can be added to a view in the following manner.

View (“Index”):

@Html.Action("HomePartial")

@Html.TextArea("textBox", new { style = "width: 100%; height: 150px;"})

Partial View - “HomePartial”:

@Html.DevExpress().SpellChecker(settings =>
{
    settings.Name = "SpellChecker";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "HomePartial" };

    settings.CheckedElementID = "textBox";
    settings.Culture = new System.Globalization.CultureInfo("en-US");
    settings.Dictionaries.AddISpellDictionary(d =>
    {
        d.AlphabetPath = "~/Dictionaries/EnglishAlphabet.txt";
        d.GrammarPath = "~/Dictionaries/english.aff";
        d.DictionaryPath = "~/Dictionaries/american.xlg";
        d.CacheKey = "ispellDic";
        d.Culture = new System.Globalization.CultureInfo("en-US");
        d.EncodingName = "Western European (Windows)";
    });
}).GetHtml()

Note

The Partial View should contain only the extension’s code.

Controller (“Home”):

public class HomeController : Controller
{
    public ActionResult Index()
    {
        return View();
    }

    public ActionResult HomePartial()
    {
        return PartialView("HomePartial");
    }
}

The code result is demonstrated in the image below.

MVCSpellChecker Overview