sharepoint:以编程方式将现有网站栏添加到现有内容类型
var objWeb =properties.Feature.Parent as SPWeb;
SPContentType contentType = objWeb.ContentTypes["Wiki Page"];
if (!contentType.Fields.ContainsField("Keywords"))
{
SPField field = objWeb.Fields["Keywords"];
SPFieldLink fieldLink = new SPFieldLink(field);
contentType.FieldLinks.Add(fieldLink);
contentType.Update(true);
}
我在功能激活中使用此代码将网站栏“关键字”添加到网站内容类型“维基页面”我的问题是“关键字”添加到“维基页面”中,但不是从现有网站栏添加新网站栏。我的代码有问题吗?
另一件事是,当我在 Office365 上部署时,此代码在我的 MOSS 服务器上运行良好,我发现了这个问题
var objWeb = properties.Feature.Parent as SPWeb;
SPContentType contentType = objWeb.ContentTypes["Wiki Page"];
if (!contentType.Fields.ContainsField("Keywords"))
{
SPField field = objWeb.Fields["Keywords"];
SPFieldLink fieldLink = new SPFieldLink(field);
contentType.FieldLinks.Add(fieldLink);
contentType.Update(true);
}
I use This code in feature activation to add site column "KeyWord" to site content type "Wiki Page" my problem is "keyword" add in "wiki page" but not from the existing site column it's add new site column. is there problem in my code?
one other thing this code works fine on my MOSS server when i deploy on office365 this problem i found
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该尝试下面的代码:
我希望有人能从我的代码中得到帮助:)
You should try the code below:
I hope someone is being helped from my code :)