Back to Devexpress

ASPxSpellChecker.CustomDictionaryLoading Event

aspnet-devexpress-dot-web-dot-aspxspellchecker-dot-aspxspellchecker.md

latest4.3 KB
Original Source

ASPxSpellChecker.CustomDictionaryLoading Event

Fires when a custom dictionary is loading into a session.

Namespace : DevExpress.Web.ASPxSpellChecker

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

NuGet Package : DevExpress.Web

Declaration

csharp
public event CustomDictionaryLoadingEventHandler CustomDictionaryLoading
vb
Public Event CustomDictionaryLoading As CustomDictionaryLoadingEventHandler

Event Data

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

PropertyDescription
CustomDictionaryGets the custom dictionary to be loaded.

Remarks

Handle the CustomDictionaryLoading event and use the ASPxSpellCheckerCustomDictionary.LoadFromStream method to load a custom dictionary, other than the default.

To save a custom dictionary when a word is added to it, handle the ASPxSpellChecker.WordAdded event.

The following code snippet illustrates that you can handle the ASPxSpellChecker.CustomDictionaryLoading event to load a custom dictionary from a stream. Note that the ASPxSpellChecker control already has an ASPxSpellCheckerCustomDictionary object in its collection of dictionaries. When the custom dictionary is loading, it fires an event allowing you to load a user-specific dictionary.

View Example

csharp
using DevExpress.Web.ASPxSpellChecker;
using DevExpress.XtraSpellChecker;
        protected void ASPxSpellChecker1_CustomDictionaryLoading(object sender, CustomDictionaryLoadingEventArgs e) {

            FileStream alphStream = new FileStream(Server.MapPath(e.CustomDictionary.AlphabetPath), FileMode.Open, FileAccess.Read);
            FileStream dicStream = new FileStream(userDictPath, FileMode.OpenOrCreate, FileAccess.Read);
            try {
                alphStream.Seek(0, SeekOrigin.Begin);
                dicStream.Seek(0, SeekOrigin.Begin);
                e.CustomDictionary.LoadFromStream(dicStream, alphStream);
            }
            finally {
                alphStream.Dispose();
                dicStream.Dispose();
            }
        }
vb
Imports DevExpress.Web.ASPxSpellChecker
Imports DevExpress.XtraSpellChecker
        Protected Sub ASPxSpellChecker1_CustomDictionaryLoading(ByVal sender As Object, ByVal e As CustomDictionaryLoadingEventArgs)

            Dim alphStream As New FileStream(Server.MapPath(e.CustomDictionary.AlphabetPath), FileMode.Open, FileAccess.Read)
            Dim dicStream As New FileStream(userDictPath, FileMode.OpenOrCreate, FileAccess.Read)
            Try
                alphStream.Seek(0, SeekOrigin.Begin)
                dicStream.Seek(0, SeekOrigin.Begin)
                e.CustomDictionary.LoadFromStream(dicStream, alphStream)
            Finally
                alphStream.Dispose()
                dicStream.Dispose()
            End Try
        End Sub

See Also

GetCustomDictionary()

WordAdded

ASPxSpellChecker Class

ASPxSpellChecker Members

DevExpress.Web.ASPxSpellChecker Namespace