When the DevExpress ASP.NET Web Forms Spell Checker finds a word missing from dictionaries, the control displays the check spelling form. This form allows users to correct, skip, or ignore the word. In this example, the ASPxSpellChecker control corrects spelling automatically.
[!NOTE]
In the example, the Spell Checker replaces a misspelled word with the first word from the suggestion list. As a result, the control may correct words incorrectly.
Files to Review
- Default.aspx (VB: Default.aspx)
- Default.aspx.cs (VB: Default.aspx.vb)
Documentation
More Examples
- ASP.NET Web Forms Spell Checker - Getting Started
- ASP.NET Web Forms Spell Checker - How to retrieve and display misspelled words
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
ASPx<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="DevExpress.Web.v13.1, Version=13.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web" TagPrefix="dx" %>
<%@ Register Assembly="DevExpress.Web.ASPxSpellChecker.v13.1, Version=13.1.14.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
Namespace="DevExpress.Web.ASPxSpellChecker" TagPrefix="dx" %>
<!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>How to perform automatic spell checking</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<dx:ASPxMemo ID="memo" runat="server" Height="70px" Width="563px" Text="Accordnig to an englnsih unviersitry sutdy the oredr of letetrs in a word dosen't mttaer, the olny thnig thta's imporantt is that the frsit and last ltteer of eevry word is in the crrecot psoition. The rset can be jmbueld and one is stlil able to read the txet withuot dificultfiy.">
</dx:ASPxMemo>
<dx:ASPxButton ID="btn" runat="server" Text="Check Spelling" OnClick="btn_Click">
</dx:ASPxButton>
</div>
</form>
</body>
</html>
C#using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.XtraSpellChecker;
using DevExpress.Web.ASPxSpellChecker;
using System.Globalization;
using System.IO;
public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void btn_Click(object sender, EventArgs e) {
String correctedText = CheckText(memo.Text);
memo.Text = correctedText;
}
String CheckText(String text) {
SpellCheckerBase checker = new SpellCheckerBase();
checker.NotInDictionaryWordFound += new NotInDictionaryWordFoundEventHandler(checker_NotInDictionaryWordFound);
SpellCheckerISpellDictionary dict = new SpellCheckerISpellDictionary(Server.MapPath("~/Dictionaries/american.xlg"),
Server.MapPath("~/Dictionaries/english.aff"),
new CultureInfo("en-us"));
dict.AlphabetPath = Server.MapPath("~/Dictionaries/EnglishAlphabet.txt");
dict.CacheKey = "ispellDic";
dict.Load();
checker.Dictionaries.Add(dict);
checker.LevenshteinDistance = 4;
String result = checker.Check(text);
return result;
}
void checker_NotInDictionaryWordFound(object sender, NotInDictionaryWordFoundEventArgs e) {
e.Result = SpellCheckOperation.ChangeAll;
e.Handled = true;
}
}