none
Using Server side code how to retrieve the Manage metadata of a current page properties ? RRS feed

  • Question

  • HI,

    I have many custom properties define in the page.In that i have managed metadata property control.

    So Using Server side code, how to retrieve the Manage metadata of  current page properties ?

    I have to fetch the managed metadata field value into some label.

    so please help.?

    Thursday, December 6, 2018 3:14 PM

All replies

  • https://sharepoint.stackexchange.com/questions/79886/how-to-read-managed-metadata-value-from-splistitem

    Justin Liu Office Servers and Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    Friday, December 7, 2018 1:31 AM
  • Hi,

    We can create a visual web part and add a Label control. Then use the code below to get the Manage Metadata field values of the current page properties. In my test, the manage metadata field name is "TestMMField" and it allow select multiple values.

    VisualWebPart1.ascx:

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    VisualWebPart1.ascx.cs:

    protected void Page_Load(object sender, EventArgs e)
    {
    	SPWeb web = SPContext.Current.Web;
    	SPFile file = web.GetFile(SPContext.Current.Web.Url + "/" + SPContext.Current.File.Url);
    	SPListItem item = file.ListItemAllFields;
    	
    	TaxonomyFieldValueCollection tfvc = item["TestMMField"] as TaxonomyFieldValueCollection;
    	var fieldValue = "";
    	foreach (TaxonomyFieldValue tfv in tfvc)
    	{
    		fieldValue += tfv.Label + ";";
    	}
    	//if the field not allow select multiple values
    	//TaxonomyFieldValue tfv = item["TestMMField"] as TaxonomyFieldValue;
    	//this.Label1.Text = tfv.Label;
    
    	this.Label1.Text = fieldValue;
    }

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Friday, December 7, 2018 4:14 AM
    Moderator
  • Hi,

    Would you please provide us with an update on the status of your issue?

    Best Regards,
    Dennis

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Thursday, December 13, 2018 8:09 AM
    Moderator
  • Hi,

    Any update?

    If my reply help you, please mark the reply as answer, it will make others who stuck with the similar issue easier to search for valid solutions in this forum.

    Best regards,
    Dennis


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, December 18, 2018 6:52 AM
    Moderator