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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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