Skip to main content

ASPxSpellChecker.WordAdded Event

Fires when a word is added to the custom dictionary.

Namespace: DevExpress.Web.ASPxSpellChecker

Assembly: DevExpress.Web.ASPxSpellChecker.v24.2.dll

Declaration

public event WordAddedEventHandler WordAdded

Event Data

The WordAdded event's data class is WordAddedEventArgs. The following properties provide information specific to this event:

Property Description
Word Gets a word added to the dictionary.

Remarks

Use the WordAdded event to save the custom dictionary to an arbitrary location. Currently, the custom dictionary is stored in a session and cannot be shared between users. Collaboration can be established by handling two events - the WordAdded event to save a changed dictionary and the ASPxSpellChecker.CustomDictionaryLoading event to load the dictionary.

The added word is available via the WordAddedEventArgs.Word property.

This code illustrates that you can handle the ASPxSpellChecker.WordAdded event to save an updated custom dictionary to the original location. The ASPxSpellChecker.GetCustomDictionary method enables you to access a custom dictionary that is currently in use.

View Example

using DevExpress.Web.ASPxSpellChecker;
using DevExpress.XtraSpellChecker;
protected void ASPxSpellChecker1_WordAdded(object sender, WordAddedEventArgs e) {
    ASPxSpellChecker checker = send as ASPxSpellChecker;
    if (checker != null) {
        SpellCheckerCustomDictionary dic = checker.GetCustomDictionary();
        if (dic != null) {
            StringBuilder stb = new StringBuilder();
            for (int i = 0; i < dic.WordCount; i++) stb.AppendLine(dic[i]);
            using (StreamWriter writer = new StreamWriter(dic.DictionaryPath,false, Encoding.UTF8)) {
                writer.Write(stb.ToString());
            }
        }
    }
}
See Also