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

  • SEARCH
  • Home
  • 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 244605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:01:07+00:00 2026-05-11T21:01:07+00:00

I have a custom site definition, in an ONET.XML file. Can I get the

  • 0

I have a custom site definition, in an ONET.XML file.
Can I get the URL and/or the Site name of the site that is being created and use it as a parameter/moniker in the onet.xml file?

Something like this:

 <Modules>
    <Module Name="Default" Url="" Path="">
      <File Url="default.aspx" NavBarHome="True">
        <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
          <![CDATA[
                   <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/Image">
                        <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                        <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
                        <FrameType>None</FrameType>
                        <Title>[NAME OF MY SITE] or [URL]</Title>
  • 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-11T21:01:08+00:00Added an answer on May 11, 2026 at 9:01 pm

    Not to the best of my knowledge.
    I have used a solution where I add the webparts programmatically via the WebPartManager and then to set properties on that WebPart I use reflection.

    An example to add the WP to a page:

    public static void AddWebPart<T>(string webPartZone, SPFile page)
    {
        Type wpType = typeof(T);
        AspNet.WebPart webPart =
            (AspNet.WebPart)wpType.GetConstructor(new Type[0]).Invoke(new object[0]);
    
        try
        {
          page.CheckOut();                                               
          SPLimitedWebPartManager wpManager = 
             page.GetLimitedWebPartManager(AspNet.PersonalizationScope.Shared);
          wpManager.AddWebPart(webPart, "WP Zone Name", 0);
          page.CheckIn("Added web part", SPCheckinType.MajorCheckIn);
    

    and here is how to set proprties on webparts:

    public static void SetWebPartProperties<T>(Dictionary<string, string> properties,
                                               SPFile page)
    {
    
        Type wpType = typeof(T);
    
        SPLimitedWebPartManager wpManager = 
        page.GetLimitedWebPartManager(AspNet.PersonalizationScope.Shared);
    
        foreach (AspNet.WebPart wp in wpManager.WebParts)
        {
            if (wp.GetType() == wpType)
            {
                foreach (KeyValuePair<string, string> kvp in properties)
                {
                    System.Reflection.PropertyInfo pi = wpType.GetProperty(kvp.Key);
                    if (pi.PropertyType == typeof(int))
                        pi.SetValue(wp, int.Parse(kvp.Value, CultureInfo.InvariantCulture), null);
                    else if (pi.PropertyType == typeof(bool))
                        pi.SetValue(wp, bool.Parse(kvp.Value), null);
    
                    pi.SetValue(wp, kvp.Value, null);
                }
                wpManager.SaveChanges(wp);
            }
        }
        page.CheckIn("Changed properties of webpart", SPCheckinType.MajorCheckIn);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Custom List Definition (schema.xml) i have set up Site Columns (through
I have created custom posts and I want one page in my site to
I have a custom accordion script that I'm trying to adapt for another site.
I currently have a web site where users can select a custom theme. After
I have a custom site definition which includes a form library. I have a
I have created custom site column with type text and I included in one
We have a custom site written in Perl that uses a slightly modified version
I have created a custom list in a SharePoint site and generated a Visual
I have to create a site definition for a client that must contain pre-defined
I have custom sharepoint site xml template. sharepoint when i am creating custom site

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.