Pregunta

¿Es posible encontrar, en un elemento web, si se hace una lista de un tipo de contenido específico? O bien, ¡encontrar todas las listas que son de un tipo de contenido específico también funcionaría!

¿Fue útil?

Solución

Primero debe obtener un identificador de la lista específica, por supuesto. Hay varias formas de hacer esto. Una manera algo ineficiente, pero utilizable a nivel mundial, sería comenzar desde el SPSite:

using(SPSite site = new SPSite(siteUrl))
{
    using(SPWeb web = site.OpenWeb(webUrl))
    {
        SPList list = web.GetList(listUrl);
        SPContentTypeCollection types = list.ContentTypes;
        foreach(SPContentType type in types)
        {
            if(type.Id == typeImLookingFor.Id)
            {
                //found the content type!
            }
        }
    }
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top