Following are the steps to include out of the box spell check of SharePoint to custom web parts.
Step 1:
Add the following page directive
<%@ Register TagPrefix=”SharePoint” Namespace=”Microsoft.SharePoint.WebControls” Assembly=”Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” %>
Step 2:
Add the following controls to the bottom of the page, which gives you the JavaScript required for the spell checker to run:
<SharePoint:ScriptLink ID=”ScriptLink1″ Language=”javascript” Name=”core.js” runat=”server” />
<SharePoint:ScriptLink ID=”ScriptLink2″ Language=”javascript” Name=”bform.js” runat=”server” />
<SharePoint:ScriptLink ID=”ScriptLink3″ Language=”javascript” Name=”SpellCheckEntirePage.js” runat=”server” />
Step 3:
Add the following block of JavaScript code to your page:
function doSpellCheck()
{
SpellCheckEntirePage(‘/_vti_bin/SpellCheck.asmx’, ‘/_layouts/SpellChecker.aspx’);
}
Step 4:
Create a link or a button and add the JavaScript method on click event
<a href=”javascript:doSpellCheck()”>Spelling…</a>
Or
<asp:Button ID=”btnSaveAsDraft” runat=”server” onclick=” javascript:doSpellCheck()” />
However using a link would prevent your page from postback.
If you do not want to spell check against some controls then add the attribute excludeFromSpellCheck=”true” to any control that should not be spell checked:
<asp:TextBox ID=”txtDontSpellCheck” runat=”server” CssClass=”txtclass” excludeFromSpellCheck=”true”></asp:TextBox>