1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Obtaining Tags from ContentTagEditor Control

Obtaining Tags from ContentTagEditor Control

4 posts, 0 answered
  1. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    06 Apr 2009
    Link to this post
    I'm trying retrieve the tags from the ContentTagEditor to that I can apply them to a news item using the NewsManager.Content.SaveTags() call.

    The control isn't documented and Intellisense doesn't reveal anything obvious.

    Can you show me how I can apply the tags a user enters in this control to a content item?

    Thanks,
    Jeff
  2. Parvan
    Parvan avatar
    151 posts
    Registered:
    24 Sep 2012
    10 Apr 2009
    Link to this post
    Hello Jeff,

    I have attached an example showing you how to use the ContentTagEditor control.
    You need to set the provider name (default provider for news is "News") and the news item you want to edit.

    IContent yourItemToEdit = null
        ContentManager manager = null
     
        protected void Page_Load(object sender, EventArgs e) 
        { 
            // these settings you need to set - the provider name and the item you want ot edit 
            string yourProviderName = "News"
            manager = new ContentManager(yourProviderName); 
            yourItemToEdit = manager.GetContent()[0] as IContent; 
     
     
            IContentTagEditor tagEditor = contentTagEditor as IContentTagEditor; 
            tagEditor.ProviderName = yourProviderName; 
            tagEditor.ContentId = yourItemToEdit.ID; 
            contentTagEditor.Changed += new ContentTagEditor.ChangedEventHandler(contentTagEditor_Changed); 
            saveTags.Click += new EventHandler(saveTags_Click); 
        } 
     
        void saveTags_Click(object sender, EventArgs e) 
        { 
            //some other action 
        } 
     
        void contentTagEditor_Changed(object sender, ContentTagEditor.TagEditorChangedEventArgs e) 
        { 
            List<string> tagsToSave = e.selectedTags; 
            if (yourItemToEdit != null && manager != null
            { 
                // Save your tags or do something with them 
                manager.SaveTags(yourItemToEdit.ID, tagsToSave); 
            } 
        } 

    Subscribe for the Changed event and save the tags for the news item.

    Greetings,
    Parvan
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. Jeff
    Jeff avatar
    124 posts
    Registered:
    05 Aug 2007
    10 Apr 2009
    Link to this post
    Thanks. I'll give it a try. It looks very promising.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Apr 2009
    Link to this post
    Hello Jeff,

    Let us know if you get stuck somewhere with provided sample.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered