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 am attempting to use a Taxonomy Picker Control (TaxonomyWebTaggingControl) on an Application Page based on the term set configured for a User Profile property. In this scenario, I have set the Ask Me About field to use a Term Set in the User Profile Service Application. When editing a user profile through the My Site or Central Admin, the field correctly displays as a Taxonomy Picker and allows me to select values from the Term Set.

In a new Application Page, I have registered the tag prefix:

<%@ Register Tagprefix="Taxonomy" Namespace="Microsoft.SharePoint.Taxonomy" Assembly="Microsoft.SharePoint.Taxonomy, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

And in the content I have added the control:

<Taxonomy:TaxonomyWebTaggingControl id="ngAskMeAbout" runat="server" />

In the Page_Load, I am first obtaining the term set from the User Profile property and then using it to get the term set from the Taxonomy Session:

var site = SPContext.Current.Site;
var context = SPServiceContext.GetContext(site);
var configMgr = new UserProfileConfigManager(context);
var propertyMgr = configMgr.ProfilePropertyManager;
var corePropertyMgr = propertyMgr.GetCoreProperties();

var askMeAbout = corePropertyMgr.GetPropertyByName("SPS-Responsibility");

var termSet = askMeAbout.TermSet;

ngAskMeAbout.Disabled = false;
ngAskMeAbout.Enabled = true;
ngAskMeAbout.Visible = true;

var taxonomySession = new TaxonomySession(site);
var termStoreId = termSet.TermStore.Id;
var termGroupId = termSet.Group.Id;
var termSetId = termSet.Id;

ngAskMeAbout.SspId.Add(termStoreId);
ngAskMeAbout.GroupId = termGroupId;
ngAskMeAbout.TermSetId.Add(termSetId);

ngAskMeAbout.AllowFillIn = false;
ngAskMeAbout.IsMulti = true;
ngAskMeAbout.IsAddTerms = false;
ngAskMeAbout.IsDisplayPickerButton = true;
ngAskMeAbout.IsIncludeTermSetName = true;
ngAskMeAbout.IsUseCommaAsDelimiter = false;
ngAskMeAbout.Language = taxonomySession.TermStores[termStoreId].DefaultLanguage;
ngAskMeAbout.AnchorId = Guid.Empty;
ngAskMeAbout.ExcludeKeyword = false;
ngAskMeAbout.IsIgnoreFormatting = false;
ngAskMeAbout.IsIncludeDeprecated = false;
ngAskMeAbout.IsIncludePathData = false;
ngAskMeAbout.IsIncludeUnavailable = false;
ngAskMeAbout.IsSpanTermSets = false;
ngAskMeAbout.IsSpanTermStores = false;

When I try running this, nothing renders on the page. I have debugged/stepped through the code to verify all the IDs are getting set properly and nothing generates an error.

Any ideas?

share|improve this question
    
Update: This code does work in a web part, however it simply does not display when displayed in an application page (in the layouts folder). Need to figure out why... –  John Chapman Jun 26 '12 at 15:08
    
Update 2: I have narrowed this down to an issue with the My Site host. If I view the application page from elsewhere on my SharePoint site, it works fine. However, when viewing it within the My Site host (http:// localhost /my/_layouts/...) it does not display. –  John Chapman Jun 26 '12 at 15:19

2 Answers 2

up vote 0 down vote accepted

So, I did end up discovering the cause of the issue, however I think it is more of a bug in SharePoint:

When the solution is deployed as a Web feature to the My Site web, it causes the error to occur. If I change the solution to be a Site feature and deploy it to the My Site Site Collection, the error does not occur.

share|improve this answer
    
I am getting the same issue even if I deploy the feature as Site feature.. Do you have any idea? then please suggest... –  users1100 Oct 3 '13 at 6:45

It appears that the Left Navigation control calls a JavaScript function called "HideQuickLaunchMenu()". For whatever reason, that function is undefined when it is called from my application page. And thus it breaks the JavaScript for the taxonomy control. As a remedy for my page, I added a blank function with the same name:

<script type="text/javascript">
    function HideQuickLaunchMenu() {
    }
</script>

Doing this made the taxonomy control work properly again. That function probably exists in one of the SharePoint JavaScript files (not in Core.js or SP.js, checked those), however I was unable to find it. The code above works for me, so I will just go with that.

share|improve this answer

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.