2

I am able to get Web template by checking its ID, but we have ten's of web configurations within a web template

so in short we have loads of web template id's with different configurations and Title.

In this question I find out how to find web template ID

Get Web Template Question

But I want to get web template by Configuration ID, not just Web.WEBTemplateID

 using (SPSite site = new SPSite(siteUrl))
            using (SPWeb web = site.OpenWeb())
            {
                foreach (SPWebTemplate template in site.GetWebTemplates(uint.Parse("1033")))
                {
                    if (template.ID == web.WebTemplateId || template.Name == web.WebTemplate)
                    {
                         //it gives me first or maybe last web template with id let say "10023" but i want to filter them with configuration id
                    }
                }
            }
1

Following code worked for me :)

  try
    {
        using (SPSite site = new SPSite(siteUrl))
        using (SPWeb web = site.OpenWeb())
        {
            foreach (SPWebTemplate template in site.GetWebTemplates(uint.Parse("1033")))
            {
                if (web.WebTemplate + "#" + web.Configuration.ToString() == template.Name &&
                    template.ID == web.WebTemplateId)
                {
                    tbTemplateCategory.Text = template.DisplayCategory;
                    tbTemplateTitle.Text = template.Title;
                }
            }
        }
    }

Hope it helps if someone else came across same problem :)

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.