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

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

Programmatically create publishing page and fill with content.

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :SharePoint

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.


View Complete Post

More Related Resource Links

Create buttons for "new item" which create a new page of a specific content type

We have a Pages library (wiki) which supports a few content types (and page layout associated). We want to enable users to click a button for example of "new custom enterprise wiki page" - so a new page of content type article will be open in edit mode. Can someone help how to develop? (it has to mimic the behavior that happens when user creates new page from the Ribbon or Site actions and has to choose the content type, it also has to keep the new page in edit mode and not just create it).  

Create a Page Layout for Enterprise Wiki with content

I need to create a Page Layout that for an Enterprise Wiki Page that already has content in the Rich Text HTML Field so when people go in to create a new page based off of the Page Layout they can go in and just replace the text with their own. Can this be done?

content editor web part in publishing page

I have created a page in pages library using my custom pagelayout and added a cewp.I also added some images from image library in source code of cewp where each image is link and takes to a diff page.this doent work in a publishing page but works fine in other pages any suggestions

How to create a Table of content in .rdl design in BIDS dynamically according to the Page no wise..?



well i am able to create the TOC statically by using the Document Map properties as describe in my older post issue 

but now i just want to create the Table of contents dynamically generate using the page no wise..is it possible...how can we do it while designing the .rdl in BIDS..



Checking publishing page content



I want to check if all my publishing pages contain specific URLs, is there a quick way to do something like a "Find". E.g. in SPD? But I guess that works only for pagelayout or master page, not publishing pages. Please advice.

Thanks in advance.

I can not create Article page in publishing site with a error message related to Microsoft SharePoin


I installed MOSS 2010 successfully with all requirements and options. After that It created a Publishing site. But, when I create an article page for news, the error page show that:


File Not found Trouble Shoot issues with Microsoft SharePoint Foundation (*).

Correlation ID: 5cce256-b30b-477d-9820-c46238f224a

Date and Time: ...


*:it's a link to open an error windows like this Besides, if i create a site with other templates (not Publishing template), I can not also start Publishing feature

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

Programmatically create a web part page in wss 3.0?

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

Best way to create a new page in Publishing site?

When creating a new page in a publishing site, is there any essential difference between choosing the "Article page with body only" option versus the "Blank Web Part Page" onto which one puts a Web Content Editor web part?  I know that they render differently on the page, but is the content box on the article page just a content editor web part without the chrome?
There are no mistakes; every result tells you something of value about what your are trying to accomplish.

Cannot Edit Multiple Publishing Html Fields (Additional Page Content Fields)



I’ve added new Columns of type HTML, I’ve added these columns to my content type and the follow in my page layout:

<div id="featureArea">

<PublishingWebControls:RichHtmlField ID="rhfFeatureArea" FieldName="FeatureArea"

Inheriting from publishing page content type does not allow for overriding fields in SharePoint 2010


Hi there, we are creating custom content types that inherit from the "Page" content type.  We have found that we must have the "Inherits" property set to "TRUE" or else our custom content types do not show up in the content type gallery.  If we query the site collection using management shell the content type does appear to be there, but unfortunately it will not publish from the content type hub. If we set Interits=TRUE the content type deploys properly and appears in the content type gallery, but we cannot override (change the display name) or remove any of the inherited fields. Ultimately, we would like to have our content types inherit from "Page" and also override some of the "Page" fields, but this does not appear to be possible. We have spent quite a bit of time on this issue and are wondering if this is a bug or intential behavior of the "Page" content type. Any information you can provide would be appreciated? 

P.S. We have ran similar tests inheriting from "Document" and "Item" content types and do not encounter the same issue with overriding inherited fields.


Unique content within master page based on conditions met


 Hi all-

I would like to present users with unique content based on certain conditions being met as they land on the home page (default.aspx).  The condition logic will be in the VB code behind Page Load event. The content will go in a content placeholder as specificed from the master page. 

However, the content change wouldn't be something small (ie making a panel or label visible or not) but rather it will be different HTML,  Divs and databound gridview content.  The HTML content will be stored in the database.

Can someone point me in the right direction for best practices on how to accomplish this?


Passing Linq Statement between master and content page


I usually work with windows forms, and am just starting to work with ASP.Net, so appologies if this is a dumb question!

I have a master page which has a search button on it. The results of this are built up using a Linq statement and if there are any results, I want to display the results in a contents page.

On the masterpage, I have the following code:

Private _res

    Public Overridable ReadOnly Property SearchRes()
            Return _res
        End Get
    End Property

 Private Sub DoSearch()
   'some code to get a linq result

    If res.Any Then
            _res = res
            Server.Transfer("SearchResults.aspx", True)
            'no results
            LabelNoRes.Visible = True
        End If
 End Sub

On the SearchResults.aspx page I have this code.

Dim m As pxSite = CType(Page.Master, MasterPage)
        If m.SearchRes IsNot Nothing Then
            Label1.Text = "Results found = " & m.SearchRes.Count
        End If

m.searchRes is always nothing. 

What am I doing wrong here?


Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

Silverlight: Create a Custom Expression Encoder Publishing Plug-In


Laurence Moroney demonstrates how to employ the Expression Encoder plug-in APIs by building and debugging a simple FTP upload plug-in.

Laurence Moroney

MSDN Magazine February 2008

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

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