0

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;
            }

        }

1 Answer 1

2

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 ;

        }
2
  • Just a question before i try it out. Does it work with custom templates(created using VS) as well?
    – Ishan
    Commented Jan 29, 2015 at 12:54
  • Yes, it should work. Commented Jan 29, 2015 at 12:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.