0

I'm using a TaxonomyWebTaggingControl on a custom application page. The problem is, when I type in some chars into the controls textbox I get a correct list of suggestions. When I select a suggestion, the selected term is set in the textbox and is underlined. That means everything is valid and ok.

This is the result after selecting a term from the suggestions list

enter image description here

When i do a post back now (click on button) the selected value is gone and my control is empty! but i am able to type in chars and getting a correct list of suggestions.

enter image description here

When I select a term through the picker control the term is selected also...

enter image description here

enter image description here

but this time the value stays after post back in the textbox and is validated.

enter image description here

This is my CODE:

    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        TaxonomySession taxonomySession = new TaxonomySession(SPContext.Current.Site);
        InitTaxonomyWebTaggingControl(txSBU, taxonomySession, "SBU");
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

    private void InitTaxonomyWebTaggingControl(TaxonomyWebTaggingControl control, TaxonomySession session, string dimension)
    {
        control.GroupId = session.DefaultKeywordsTermStore.Groups[MIATermGroupName].Id;
        control.SspId.Add(session.DefaultKeywordsTermStore.Id);
        control.TermSetId.Add(session.DefaultKeywordsTermStore.Groups[MIATermGroupName].TermSets[dimension].Id);
        control.AllowFillIn = true;
        control.IsIncludePathData = true;
        control.IsMulti = false;
        control.Language = session.DefaultKeywordsTermStore.DefaultLanguage;

    }

Why is my term lost when I select the term through suggestions and why is everything after post back there when I select the term through the picker?

1

After my testing I have detected the problem: control.IsIncludePathData = true;

When you select from suggestions, control.Text contains something like this:

label | GUID| GUID | GUIDSELECTED

When you select from picker, control.Text contains:

label | GUIDSELECTED

So, you can avoid the problem with control.IsIncludePathData = false, or assigning the correct value in control.Text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.