Question

I am trying to get the web template name that is being used currently in order to create the site.

I have created and EvenReceiver and overriding WebProvisioned. in this method i would like to get the name of the template i am currently using in order to create the subsite.

I am using code below. GetCustomWebTemplates and GetWebTemplates gives list of all the templates but i am only interested in getting the name of the current one. Is it possible? any idea how can we do that? Kindly help.

using (SPSite thisSite = new SPSite(properties.FullUrl))
        {
            SPWeb thisWeb = thisSite.OpenWeb();

            SPWebTemplateCollection stc = thisSite.GetWebTemplates(thisWeb.Language);
            foreach (SPWebTemplate sc in stc)
            {
                string MyTempleName = sc.Name;
            }

        }
Was it helpful?

Solution

Use SPWeb.WebTemplate to get the name of the template.

using (SPSite thisSite = new SPSite(properties.FullUrl))
        {
            SPWeb thisWeb = thisSite.OpenWeb();

            string MyTempleName = thisWeb.WebTemplate ;

        }
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top