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.
using DevExpress.Web.Office;
using DevExpress.XtraRichEdit;
using System;
public partial class _Default : System.Web.UI.Page {
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);
}
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.ASPxRichEdit.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxRichEdit" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxSpellChecker.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxSpellChecker" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function onRichEditCustomCommandExecuted(s, e) {
if(e.commandName = "OpenSpellingDialog") {
RichEdit.commands.openSpellingDialog.execute();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<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>
</form>
</body>
</html>
<%@ Page Language="vb" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register assembly="DevExpress.Web.ASPxRichEdit.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxRichEdit" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxSpellChecker.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxSpellChecker" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v16.1, Version=16.1.6.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web" tagprefix="dx" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function onRichEditCustomCommandExecuted(s, e) {
if(e.commandName = "OpenSpellingDialog") {
RichEdit.commands.openSpellingDialog.execute();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<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>
</form>
</body>
</html>
Imports DevExpress.Web.Office
Imports DevExpress.XtraRichEdit
Imports System
Partial Public Class _Default
Inherits System.Web.UI.Page
Private documentId As String = "docId"
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
Dim server_Renamed As New RichEditDocumentServer()
server_Renamed.LoadDocument(Server.MapPath("~/SpellChecking.docx"))
DocumentManager.CloseDocument(documentId)
RichEdit.Open(documentId, DocumentFormat.OpenXml, Function() server_Renamed.OpenXmlBytes)
End If
End Sub
End Class