Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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
                    }
                }
            }
share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 :)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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