title: How do I show the correct Taxonomy control in a SharePoint 2010 EditModePanel?
body: <p>We have a custom content type in our SharePoint 2010 build which includes a Managed Metadata field for keywords.</p>
  
  <p>The field seems to have deployed OK because if I edit an item in the list in which it resides I get the correct Taxonomy picker control and my terms are retrieved from the term store.</p>
  
  <p>However; we are using an EditModePanel on the PageLayout for the item to allow in-site editing of the items and I can't get the correct Taxonomy picker control to appear.</p>
  
  <p>If I add a TaxonomyWebTaggingControl to the page layout and hardcode the SSPId etc then it works; </p>
  
  <pre><code>&lt;TaxonomyControls:TaxonomyWebTaggingControl runat="server" SSPId="234234-234234-34341-343" TermSetId="234234-23342-34234-234-234"/&gt;
  </code></pre>
  
  <p>However we can't hardcode the values as the term store will be created when the client deploys the site. </p>
  
  <p>When we create the Content type we have an Event Receiver which binds the field to the correct Term Store/Set using their names but I don't understand how to get a field in the EditModePanel to get/set these.</p>
  
  <p>What I really want is something like:</p>
  
  <pre><code>&lt;TaxonomyControls:TaxonomyWebTaggingControl runat="server" TermStore="My term store name" TermSet="Keywords"/&gt;
  </code></pre>
  
  <p>Am I missing something?</p>
  
  <p>My event receiver looks like this:</p>
  
  <pre><code> 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);
          }
  </code></pre>