Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a SharePointWebControls:UserField in a page layout that needs to be excluded from spell checking, as otherwise whenever a user is selected there are a large number of spelling errors are detected in the code-behind for the control.

It seems that in Sharepoint 2007 this behaviour could be implemented by using excludefromspellcheck = "true" but this doesn't seem to work for Sharepoint 2010. Has anyone come across the same problem and found a way around it?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

I've found one work-around, which is to use javascript to inject the "excludeFromSpellCheck" attribute onto the html rendered for the control. I name the div around the asp control something distinctive, then when the page loads scripts run that get the wrapper then iterate across child elements of type input and textarea.

Example:

var containerElement = document.getElementById('excludeContentFromSpellCheck');

var inputNodeArray = containerElement.getElementsByTagName('input');
for (var i = 0; i < inputNodeArray.length; i++) {
  inputNodeArray[i].setAttribute("excludeFromSpellCheck", "true");    
}

var textNodeArray = containerElement.getElementsByTagName('textarea');
for (var i = 0; i < textNodeArray.length; i++) {
  textNodeArray[i].setAttribute("excludeFromSpellCheck", "true");    
}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.