How to: Open SpellChecker dialog via Ribbon
- 2 minutes to read
ASPxRichEdit built-in spell checking support, including the type-as-you-go error detection. End-users can correct a misspelled word in the Spelling dialog. It can be opened using the corresponding context menu’s item when a cursor is over the misspelled word. This dialog allows a user to select spelling suggestions (they are also displayed in the context menu), change or ignore the error once or in all cases, and add a new word to the dictionary. You can also invoke the Spelling dialog using the client-side openSpellingDialog command. In this example, ASPxRichEdit includes a custom ribbon button: clicks on this item are processed using the client-side CustomCommandExecuted event. The event handler identifies the custom item via a command name and executes the openSpellingDialog command.
function onRichEditCustomCommandExecuted(s, e) {
if(e.commandName = "OpenSpellingDialog") {
RichEdit.commands.openSpellingDialog.execute();
}
}
<dx:ASPxRichEdit ID="RichEdit" runat="server" ClientInstanceName="RichEdit">
<ClientSideEvents CustomCommandExecuted="onRichEditCustomCommandExecuted" />
<Settings>
<SpellChecker Enabled="true" SuggestionCount="4">
<Dictionaries>
<dx:ASPxSpellCheckerISpellDictionary
AlphabetPath="EnglishAlphabet.txt"
GrammarPath="english.aff"
DictionaryPath="american.xlg"
Culture="English (United States)"
CacheKey="ISpellDic">
</dx:ASPxSpellCheckerISpellDictionary>
</Dictionaries>
</SpellChecker>
</Settings>
<RibbonTabs>
<dx:RibbonTab Text="Review">
<Groups>
<dx:RibbonGroup Text="Proofing">
<Items>
<dx:RibbonButtonItem
Name="OpenSpellingDialog"
Text="Spelling"
Size="Large"
LargeImage-IconID="format_spellcheck_32x32gray">
</dx:RibbonButtonItem>
</Items>
</dx:RibbonGroup>
</Groups>
</dx:RibbonTab>
</RibbonTabs>
</dx:ASPxRichEdit>
string documentId = "docId";
protected void Page_Load(object sender, EventArgs e) {
if(!IsPostBack) {
RichEditDocumentServer server = new RichEditDocumentServer();
server.LoadDocument(Server.MapPath("~/SpellChecking.docx"));
DocumentManager.CloseDocument(documentId);
RichEdit.Open(documentId, DocumentFormat.OpenXml, () => server.OpenXmlBytes);
}
}