如何在 sharepoint 2010 中从拼写检查中排除字段?

发布于 2024-10-18 01:24:49 字数 241 浏览 5 评论 0原文

我的页面布局中有一个 SharePointWebControls:UserField ,需要将其排除在拼写检查之外,否则每当选择用户时,都会在代码隐藏中检测到大量拼写错误控制。

似乎在 Sharepoint 2007 中可以通过使用 excludefromspellcheck = "true" 来实现此行为,但这似乎不适用于 Sharepoint 2010。有没有人遇到过同样的问题并找到解决方法?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

凉世弥音 2024-10-25 01:24:49

基于SpellCheckEntirePage.js,这似乎仍然是这样:

var elements=document.body.getElementsByTagName("*");
for (index=0; index < elements.length;++index)
{
    if (null !=elements[index].getAttribute("excludeFromSpellCheck"))
    {
        continue;
    }
    // snipped - if (elements[index].tagName=="INPUT")
    // snipped - else if (elements[index].tagName=="TEXTAREA")
}

但exclusionFromSpellCheck不是UserField,因此它可能不会自动复制到呈现的 HTML。呈现时,UserField 控件由多个元素组成。我会尝试查看“查看源代码”,看看 exceptFromSpellCheck 是否将其纳入最终的 HTML 中。但要在适当的元素上设置属性,您可能需要使用一些 jQuery,如下所示:

$("(input|textarea)[id*='UserField']").attr("excludeFromSpellCheck", "true");

Based on SpellCheckEntirePage.js, that appears to still be the way:

var elements=document.body.getElementsByTagName("*");
for (index=0; index < elements.length;++index)
{
    if (null !=elements[index].getAttribute("excludeFromSpellCheck"))
    {
        continue;
    }
    // snipped - if (elements[index].tagName=="INPUT")
    // snipped - else if (elements[index].tagName=="TEXTAREA")
}

But excludeFromSpellCheck is not a property of UserField, so it probably won't automatically copy down to the rendered HTML. When rendered, the UserField control is made up of several elements. I would try looking at the View Source to see if excludeFromSpellCheck is making it into the final HTML. But to set the attribute on the appropriate elements, you might need to use some jQuery like this:

$("(input|textarea)[id*='UserField']").attr("excludeFromSpellCheck", "true");
假装不在乎 2024-10-25 01:24:49

您可以通过在不希望进行拼写检查的文本区域和输入控件上将“excludeContentFromSpellCheck”属性设置为“true”来禁用某些字段的拼写检查。

我在所有页面布局上都这样做了。现在我不再收到误报了。

解决方案是在您不想进行拼写检查的字段周围添加一个 div 标签,并添加一个 javascript,将 div 标签内的元素的“excludeFromSpellCheck”设置为“true”。

我找到的解决方案如下所述:SharePoint 发布页面上的拼写检查不准确

You can disable the spell check for certain fields by setting the "excludeContentFromSpellCheck" attribute to "true" on text area and input controls that you dont want to be spell checked.

I did this on all my page layouts. Now i dont get false positives anymore.

The solution is to add a div tag around the fields you don't want spell checked and adding a javascript that sets "excludeFromSpellCheck" to "true" for the elements within the div tag.

The solution i found is described here: Inaccurate Spell Check on SharePoint Publishing Pages

烟柳画桥 2024-10-25 01:24:49

Joe Furner 发布了这个解决方案,它对我有用。
https://www.altamiracorp.com/blog/employee -posts/spell-checking-your-custom-lay

它排除页面上的所有 PeoplePicker:

function disableSpellCheckOnPeoplePickers() {
    var elements = document.body.getElementsByTagName("*");
    for (index = 0; index < elements.length; index++) {
        if (elements[index].tagName == "INPUT" && elements[index].parentNode && elements[index].parentNode.tagName == "SPAN") {
            var elem = elements[index];
            if (elem.parentNode.getAttribute("NoMatchesText") != "") {
                disableSpellCheckOnPeoplePickersAllChildren(elem.parentNode);
            }
        }
    }
}

function disableSpellCheckOnPeoplePickersAllChildren(elem) {
    try {
        elem.setAttribute("excludeFromSpellCheck", "true");
        for (var i = 0; i < elem.childNodes.length; i++) {
            disableSpellCheckOnPeoplePickersAllChildren(elem.childNodes[i]);
        }
    } 
    catch(e) {
    }
}

Joe Furner posted this solution, which has worked for me.
https://www.altamiracorp.com/blog/employee-posts/spell-checking-your-custom-lay

It excludes all PeoplePickers on the page:

function disableSpellCheckOnPeoplePickers() {
    var elements = document.body.getElementsByTagName("*");
    for (index = 0; index < elements.length; index++) {
        if (elements[index].tagName == "INPUT" && elements[index].parentNode && elements[index].parentNode.tagName == "SPAN") {
            var elem = elements[index];
            if (elem.parentNode.getAttribute("NoMatchesText") != "") {
                disableSpellCheckOnPeoplePickersAllChildren(elem.parentNode);
            }
        }
    }
}

function disableSpellCheckOnPeoplePickersAllChildren(elem) {
    try {
        elem.setAttribute("excludeFromSpellCheck", "true");
        for (var i = 0; i < elem.childNodes.length; i++) {
            disableSpellCheckOnPeoplePickersAllChildren(elem.childNodes[i]);
        }
    } 
    catch(e) {
    }
}
一刻暧昧 2024-10-25 01:24:49

此代码仅部分工作,因为如果您再次放置人员选择器值,请检查人员选择器垃圾值一次。

This code is working partially only,because if you put the people picker value again checking the people picker garbage value for one time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文