如何在SharePoint 2010 EditModePanel中显示正确的分类法控件?

我们的SharePoint 2010版本中包含自定义内容类型,其中包含关键字的托管元数据字段。 该字段似乎已部署好,因为如果我编辑它所在的列表中的项目,我将获得正确的Taxonomy选择器控件,并从术语库中检索我的术语。 然而;我们在PageLayout上使用EditModePanel来允许项目的现场编辑,我无法显示正确的Taxonomy选择器控件。 如果我将TaxonomyWebTaggingControl添加到页面布局并对SSPId等进行硬编码,那么它可以工作;
<TaxonomyControls:TaxonomyWebTaggingControl runat="server" SSPId="234234-234234-34341-343" TermSetId="234234-23342-34234-234-234"/>
但是,我们无法对值进行硬编码,因为客户端部署站点时将创建术语库。 当我们创建Content类型时,我们有一个Event Receiver,它使用它们的名称将字段绑定到正确的Term Store / Set,但我不明白如何在EditModePanel中获取/设置这些字段。 我真正想要的是:
<TaxonomyControls:TaxonomyWebTaggingControl runat="server" TermStore="My term store name" TermSet="Keywords"/>
我错过了什么吗? 我的事件接收器看起来像这样:
 try
        {
            SPSite site = ((SPWeb)properties.Feature.Parent).Site as SPSite;

            Guid fieldId = new Guid("3211B052-5332-424C-A066-BBE21AEAB878");
            if (site.RootWeb.Fields.Contains(fieldId))
            {
                TaxonomySession session = new TaxonomySession(site);

                if (session.TermStores.Count != 0)
                {
                    var termStore = session.TermStores["Managed Metadata Service"];
                    var group = termStore.Groups.GetByName("My Client");
                    var termSet = group.TermSets["Keywords"];

                    TaxonomyField field = site.RootWeb.Fields[fieldId] as TaxonomyField;

                    field.SspId = termSet.TermStore.Id;
                    field.TermSetId = termSet.Id;
                    field.AnchorId = Guid.Empty;
                    field.AllowMultipleValues = true;
                    field.TextField = fieldId;
                    field.TextField = new Guid("{574C5BCE-74E8-40C8-BE90-C9338135D491}");
                    field.Update();
                    Log.Logger.LogEvent("ContentType Activation", "Updated keywords field with MMS details");
                }
            }
        }
        catch (Exception ex)
        {
            Log.Logger.LogException(ex, "Content Type Activation", ex.Message);
        }
    
已邀请:
您应该使用TaxonomyFieldControl:
<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<Taxonomy:TaxonomyFieldControl FieldName="My Field Name" runat="server" id="myField"/>
    

要回复问题请先登录注册