Spell Check Web Service in Share Point - Excluding SharePoint Controls

Published 20 March 08 02:14 AM | abartucciotto 

Todays task seemed simple enough, get the spell check web service running on a custom control embedded in a share point page. Where to start? Looking for documentation on the web I could not find anything remotely helpful until I stumbled upon a blog by Hoo Kai Sheng. This helped get the ball rolling. It out lines the easiest way to get the spell checker working, that is using the SpellCheckEntirePage javascript function.

As the name suggests this spell checks all the text fields on page. It skips drop down lists and multiple select boxes but any other form control with a text input seems fair game. This means Share Point controls such as the people picker (SharePoint:PeopleEditor) will get checked as well. This is not very user friendly as we do not want the checker asking people to fix their domain names and user names.

 The trick to exclude SP controls is to search the page the SP is on and find the text input box that resides within it. In this case the SharePoint:PeopleEditor contains several hidden fields, we don't need to worry about these, and also an input field which is called "downlevelTextBox". This is the one we want to exclude. Because we are using custom ascx controls, in the code behind, we can use the FindControl method on our SharePoint:PeopleEditor. In the example below textboxEscalationManager is the people picker ID.

                TextBox textboxEscalationManager = (TextBox)PeopleEditorEscalationManager.FindControl("downlevelTextBox");
                textboxEscalationManager.Attributes.Add("excludeFromSpellCheck", "true");

When the page renders the control it now has the attribute - excludeFromSpellCheck and will not be checked by the Spell Checker.

Comments

# CSharpZealot said on March 23, 2008 9:57 PM:

Excellent solution Andrew...good work!

How about showing a solution that'll exclude "all" other fields, barring one specific field without having to specify each individual one in the page?

Iterating through the fields on the form and excluding those it finds?

# Brian H. Madsen - .Net Powered by Caffeine said on March 24, 2008 5:27 PM:

How smart is this guy?? In just one day he cut down a massive task of mine on the project we're working

Anonymous comments are disabled