Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3721702
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:38:51+00:00 2026-05-19T05:38:51+00:00

From code I’ve automatically created a lot of similar sites (SPWeb) in my site

  • 0

From code I’ve automatically created a lot of similar sites (SPWeb) in my site collection from a site template (in Sharepoint Foundation). Every site has a home page on which I’ve added the “what’s new” web part (found under “Social collaboration”).

Even though the web part has several “target lists” (I’d have called it “source lists”) added to it on the template site, this connection is lost on the sites created from the template. So I need to programmatically find all these web parts and add the target lists to them. Looping the web parts is not an issue – I’ve done that before – but I can’t seem to find a word on the net on how to go about modifying this particular web part. All I have is a brief intellisense.

I’ve found out that it recides in the

Microsoft.SharePoint.Applications.GroupBoard.WebPartPages 

namespace, but on the lists provided on MSDN this is one of very few namespaces that doesn’t have a link to a reference documentation.

Does anyone have any experience of modifying this web part from code? If not, how would you go about to find out? I can’t seem to figure out a method for this..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:38:52+00:00Added an answer on May 19, 2026 at 5:38 am

    Here is how I did it. It worked really well. I had a feature that created several list instances and provisioned the What’s New web part. In the Feature Receiver, I looped through all of the list instances, indexed the Modified field, and then added the list to the web part:

    private void ConfigureLists(SPWeb web, SPFeatureReceiverProperties properties)
    {
        List<Guid> ids = new List<Guid>();
        SPElementDefinitionCollection elements = 
            properties.Feature.Definition.GetElementDefinitions(new CultureInfo((int)web.Language, false));
        foreach (SPElementDefinition element in elements)
        {
            if ("ListInstance" == element.ElementType)
            {
                XmlNode node = element.XmlDefinition;
                SPList list = web.Lists[node.Attributes["Title"].Value];
                SPField field = list.Fields[SPBuiltInFieldId.Modified];
                if (!field.Indexed)
                {
                    field.Indexed = true;
                    field.Update();
                }
                ids.Add(list.ID);
            }
        }
    
        string targetConfig = string.Empty;
        foreach (Guid id in ids)
        {
            targetConfig += string.Format("'{0}',''\n", id);
        }
        SPFile file = web.GetFile("Pages/default.aspx");
        file.CheckOut();
        using (SPLimitedWebPartManager manager = file.GetLimitedWebPartManager(PersonalizationScope.Shared))
        {
            WhatsNewWebPart webpart = null;
            foreach (System.Web.UI.WebControls.WebParts.WebPart eachWebPart in manager.WebParts)
            {
                webpart = eachWebPart as WhatsNewWebPart;
                if (null != webpart)
                {
                    break;
                }
            }
            if (null != webpart)
            {
                webpart.TargetConfig = targetConfig;
                manager.SaveChanges(webpart);
            }
        }
        file.CheckIn("ConfigureWebParts");
        file.Publish("ConfigureWebParts");
        file.Approve("ConfigureWebParts");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can i set the control.Template from code if my template is placed in
I'm trying to load a UIViewController from code. I basically created a UIViewController generating
I created this fiddle from code found on Stack, but it is firing an
I need to create sub domain from code. For example my web site register
From code how can we know which interfaces one class implements? Example: interface IDrink
With regards this example from Code Complete: Comparison Compare(int value1, int value2) { if
Here is the problem from code chef : A set of N dignitaries have
I need to change ASPxGridView SettingsLoadingPanel dynamically (from code behind if is possible). For
I am trying to make a frame from code so that I can apply
I need to open a new window from code-behind on post-back if a specific

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.