Example E2286
Visible to All Users

ASP.NET Web Forms Spell Checker - How to correct spelling automatically

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.

Correct Spelling Automatically with DevExpress ASP.NET Web Forms Spell Checker

Files to Review

Documentation

More Examples

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)

Example Code

WebSite/Default.aspx
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>
WebSite/Default.aspx.cs
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; } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.