.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Programmatically create a web part page in wss 3.0?

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :SharePoint
I understand how to create a web part page using sharepoint's nifty UI....i.e.:

- go to site actions > create > web part page

- On the 'New Web Part Page' form: give it a name, select a 'layout template', and choose a document library for it to go into to...then click create.

- On the 'edit mode' form for you new web part page: add web parts and select the appropriate options for each web part.

I need to do all of and exactly this....however I need to do it programmatically as a part of a sharepoint application page (in the code behind the application page, obviously)...in WSS 3.0.

I understand that it's possible to do this as a feature that can be added to a sharepoint site (haven't looked at the details here tho).

This doesn't work for me cuz the web part page needs to be generated dynamically (due to the fact that document libraries get generated dynamically). For context: I'm building a web part page the has several related lists (of various sorts) on one page.

Seems like this wouldn't be that uncommon a thing to do, but haven't seen anything written up about it. Is there something written that I've missed? Or does anyone have any helpful suggestions/hints for me?

thanks very much

View Complete Post

More Related Resource Links

Programmatically create publishing page and fill with content.


I have a bunch of HTML which has been exported from a different platform.
This HTML could be located in a database or contained within an HTML file. 

I am looking for some guidance on the best way to programmatically create a publishing page in SharePoint at a specific site location, then populating the RichHtmlField Publishing Web Control (PublishingPageContent) with the HTML that has been exported from one of the sources mentioned above.

Any suggestions/advice you can offer will be much appreciated.


create page with default template from master page programmatically


hi, exactly like cms , i want to create page programmatically with this options:

1: page-name

2: add template (master-page)

and etc...

help me .thanks

Want to create Page URL rewrite based on Users GUID and Display name?



I am using the asp.net membership. 

On my site I have a Profile.aspx page.

In the code behind of this page,  i get the logged in UserId (Guid) and pass

this to a method in my DAL. GetUserByUserId()


In my database I have a Table called Member which the method gets the data from

and displays details on the page about  the user.


What I want to happen is when they have logged in and are diverted to Profile.aspx,

the page URL shows www.MyWebSite/Profile/UsersName 

for example



is this possible. In my Member table I have FirstName and LastName columns or do I get the

name from the membership table.


even better would be they go straight to www.MyWebsite/JohnSmith.aspx


thank you for any help






I want to create registration page and login page


I have design form layouts for signup and login pages 

Please provide me the step by step code for sign up and login pages using c# with validation.

waiting for urgent reply

Change part of a page without full postback


I have a page with two columns. Initially, the left column will contain a list of links that are article titles. Clicking on one of the links will display the text of the article in the right column, keeping the list of titles in the left column. Clicking on another title will clear the text of the first article and display the second. Is there a way to accomplish this without having to repaint the whole page? I would rather not have the whole page resent each time a title is clicked, but rather have the page stay as is and only the contents of the right column get cleared and redisplayed. I assume there's a way to do this with JavaScript, but I don't know how and would appreciate some help. Thanks!

how to add a wiki page as a web part


Hi All,

I have created a feature that generates a page and adds a content editor web part, links web part (using elements.xml). Everything works fine but I would like to replace content editor web part with a wiki page that I am going to create.

For example, I copied an excerpt from elements.xml file that adds a content editor web part for the page.

<Module Path="Dependencies/Pages" Url="">
  <File Url="default.aspx" Type="Ghostable">
   <!-- Add the Rich Content Text Editor web part -->
   <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
          <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:iwp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
            <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
            <Title>Executive Summary</Title>

 Can someone tell me how I can add a wiki page using manifest (elements.xml) file or some other way?

Programmatically create an InfoPath form


I'm programmatically creating an InfoPath form using this article: http://www.bizsupportonline.net/infopath2007/programmatically-create-infopath-form-console-app.htm.


Everything works well up to 29 fields (my:field1 ... my:field29). After that it runs without an error and posts a form to the library however the icon does not switch to an infopath icon and the filename stays blanks. I don't believe this field specific, it seems to be happening when I use any 29 to 30 fields so I'm thinking its a memory issue with the stream reader.

Has anybody every had this issue before, is there a way to fix this?


How to create a single entry page for site collections in MOSS 2007



I have  7 site collections containing a few hundred team collaboration sites. Some users are internal (intranet) but most are external (extranet). Extranet users are experiencing problems with losing links to their sites and forgetting which URLs to use. So I would like to create a single entry page that all users can enter after the logon process, which shows a list of sites they have permission to access, and other user-specific information. Perhaps relevant documents, tasks, recently modified documents etc.

I know this sounds like a 'My Site' but we want to use use a general welcome page instead. We use Windows authentication.
What is the best way of doing this and is it something that can be done in SharePoing Designer or does it need to be done in Visual Studio?

Many thanks in advance.

how to create a wiki as page link

hi i want to create a page which should display all wikis and im looking to create a button which should redirect to the page tab with all wiki's

Add page numbers for paging in data view web part


Hello all,

Has anyone found a solution that will allow me to have page numbers for paging in a data view web part. For instance, if I have 40 items/rows and I set the paging to display 10 items, I'd like the paging to show 1 2 3 4 rather than showing 1-10 and having to click next over and over to get to a specific item.

I found this article, but it is for 2003 and doesn't seem to apply to 2007 or if it does I am not able to really figure out how.


Please help!

Thanks in advance.


Programmatically Hide Master Pages from Site Master Page Settings page?



I know there is a field you can check when you edit the properties of a Master Page in the Master Page Gallery to set a Master Page to hidden but ... can anyone think of a way to programmatically hide specific Master Pages from the Site Master Page Settings page?

Maybe this should be two questions:

  1. How do I programmatically access a Master Page in a Master Page Gallery?
  2. Is there a property that can be set that will hide the page from the Site Master Page Settings page?

Web Part working fine on the top-level page but 'Not Safe' error on lower-level pages.


I have created a Web Part which reads and parses the SharePoint logs in order to display usage information of the page it resides on.  The Web Part works perfectly on the top page, reading and displaying the information desired.  However, once the Web Part is added to any page lower in the site heirarchy (sub-page) the same Web Part throws the following error:

Web Part Error: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.

Show Error Details
Hide Error Details

[UnsafeControlException: A Web Part or Web Form Control on this Page cannot be displayed or imported. The type could not be found or it is not registered as safe.]
  at Microsoft.SharePoint.ApplicationRuntime.SafeControls.GetTypeFromGuid(Guid guid)
  at Microsoft.SharePoint.WebPartPages.SPWebPartManager.CreateWebPartsFromRowSetData(Boolean onlyInitializeClosedWebParts)

Of course the current version of the Web Part is in the SafeControls list on the web.config.

The Web Part was originally designed to return site activity only for the top default.aspx page and worked fine but started to fail in the manner described above once I added the following line of code to return a SPCo

VS2008 and C#: How to create PictureBox controls programmatically in a FlowLayoutPanel ?

I am trying to create multiple PictureBox controls in a FlowLayoutPanel programmatically. The number of the PictureBox controls is dynamic depending on the target image folder. My current approach results a compilation error:             // (Works !)             pictureBox1 = new System.Windows.Forms.PictureBox();             pictureBox1.Width = 150;             pictureBox1.Height = 150;             flowLayoutPanel.Controls.Add(pictureBox1);             string sFileFullName = "Resources\\file1.bmp";             pictureBox1.Image = Image.FromFile(@sFileFullName);             // (Error !)             string pbName = "pictureBox";             for (int i = 0; i < 100; i++)             {             

Adding a list item that populates a particular part of a page

I am trying to create a list view in sharepoint designer that when you enter a list value it populates the right part of the page. Background - I am creating a list for a marketing newsletter that when you fill out the list form it will populate the marketing newsletter on page. its to save recreating it every month. the list has drop downs for addition and department and the data is inserted on the page. thanksSharepoint Customiser

Is it possible to give parameter to the Page Viewer web part?

Page viewer web part gives iView to the website eg. http://www.test.com. This works fine! Our customer would like give parameters like http://www.test.com/abc?name=John. First question is that is it possible to give personalized parameters to the url? Any chances to give SharePoint user name as parameter?  Kenny_I

How to Create Page layout only for webpart zone

HI Guys, I want to Create Page layout for Publishing site in SP2010 so do i need to create Page Layout Based on Page content Type ? i have created page layout based on Page content type but when i save page i got error Invalid SPListItem. The SPListItem provided is not compatible with a Publishing Page. Please assist me.   Thanks Ronak Thanks Ron

Add webpart programmatically to page in sharepoint

Hi How to add webpart programmaticaly in sharepoint ? CheersMomo
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend