Con risposta get content type id

  • Thursday, May 10, 2012 3:23 PM
     
     

    I have a task list.

    in that there are 3 content types.

    I want to make different custom action buttons according to the content type.

    the problem is how to identify the content type id?

    RegistrationType="ContentType"
    RegistrationId ="0x0100D76B3817D18C4a97D3B1742271806CCF"

All Replies

  • Thursday, May 10, 2012 6:00 PM
    Answerer
     
     

    Hello,

    I'm not sure I've understood your question but if you want to know the id of a content type,list content type, go to the list parameter, clicl on the content type et check the url, you should see the ctype parameter which is the content type

    Hope this help!


    Best regards, Christopher.
    Blog | Mail

  • Friday, May 11, 2012 6:32 AM
     
     Answered Has Code

    Hey,

    I am not actually why you are geting so troubled while finding the ID of content type

    sing System;
    using Microsoft.SharePoint;
    
    namespace Test
    {
       class ConsoleApp
       {
          static void Main(string[] args)
          {
             using (SPSite site = new SPSite("http://localhost"))
             {
                using (SPWeb web = site.OpenWeb())
                {
                   // Search for a built-in content type on lists in the site.
                   SPContentTypeId parentId = SPBuiltInContentTypeId.Document;
                   foreach (SPList list in web.Lists)
                   {
                      SPContentTypeId matchId = 
                         list.ContentTypes.BestMatch(parentId);
                      // Report a match only if the list is not hidden 
                      // (e.g. Master Page Gallery).
                      if (parentId.IsParentOf(matchId) && !list.Hidden)
                      {
                         Console.WriteLine("{0} has the {1} content type.",
                                            list.Title, 
                                            list.ContentTypes[matchId].Name);
                         Console.WriteLine("parent content type id: {0}",
                                            parentId.ToString());
                         Console.WriteLine("  list content type id: {0}", 
                                            matchId.ToString());
                      }
                   }
                }
             }
             Console.Write("\nPress ENTER to continue...");
             Console.ReadLine();
          }
       }
    }

    Following link wil help you out

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spcontenttype.id.aspx


    "The Only Way To Get Smarter Is By Playing A Smarter Opponent"

    • Marked As Answer by Shimin Huang Friday, May 18, 2012 5:36 AM
    •  
  • Wednesday, May 23, 2012 4:34 AM
     
     

    I've got FileNotFoundException in using (SPSite site = new SPSite(http://myhost))

  • Wednesday, May 23, 2012 5:02 AM
    Answerer
     
     

    Hello,

    check if your application is build in x64 and compile in 3.5.

    I've made a topic about this error here : http://christopherclementen.wordpress.com/2012/03/02/windows-application-spsite-filenotfound/ 

    Hope this help!


    Best regards, Christopher.
    Blog | Mail