MonoX support board

Start the conversation, ask questions and share tips and solutions with fellow developers.

Non-registered users can only browse through our support boards. Please register now if you want to post your questions. It takes a second and it is completely free. Alternatively, you can log in without registration using your credentials at major sites such as Google, Microsoft Live, OpenId, Facebook, LinkedIn or Yahoo.

Creating New Pages - StorePocedure Programatically  (Mono Support )

Viewed 12028 time(s), 3 post(s) 3/31/2011 11:45:47 AMby peterg


3/31/2011 11:45:47 AM
Hi Denis, Khorvat,

Creating pages are simple and very easy using the Admin Module,

My question is I have a list of pages 100 or so witch I need to add pages for, this will save a hudge amount of time if it can be done programatically or by some means of a script.

Here is my plan
I can create pages with a program...thanks to my wife this program will look at a list with two columbs...FileName and a Page Name, the file name will then become My_File_Name.aspx and the Page Name will become the Title of the page, the description. The rest of the page code will pretty much be a default content page code, same as when you generate the page by the admin module.

The Two tables im looking into is : Page and PageLocalization

So now I have a few things Im looking at:
Keyword generator - will the MonoX software still generate keywords for this page? Im not to bothered by this as most search enjines dont bother with keywords anymore.

Seach - Will the site search still find this page

anything else I might frst need to have a look at before I try this out?

Do you cleve4r guys think this will work...eeerrmm the asnswer is Anything Is Possible with MonoX :)


This content has not been rated yet. 
246 Reputation 35 Total posts


3/31/2011 12:54:36 PM
Hi Peterg,

of course you can programatically  create pages and generally you are on the right track but here are the few more tips so you can create everything without a problem.

1. Iterate through the list of your files / pages and with the program you have copy (or create) the files (as you mentioned " My_File_Name.aspx") - be sure that created or copied file contains the proper mark-up, you can find an example of proper mark-up (of empty page) in "/App_Templates/Default/PageTemplates/DefaultTemplate.aspx" which contains the columns template with two zones and document editors (so you can add the content you want)
2. Insert a record for every page you create to "Page" and set the title of the page in "PageLocalization" (as you have mentioned)
3. If you want to insert default content (that can be dynamically changed) in these files then you need to insert content in MonoX Editors (placed in the Zones mentioned above). There are two ways that you can to this:
3.1 Insert default content by parsing the file and place the content in DefaultContent inside the Editor (example is below)
<MonoX:Editor runat="server" ID="editor1" Title='Left section' DefaultDocumentTitle='Left section' >
    <h2>Content Management</h2>
    <img src="/App_Themes/Default/img/content-management-icon.png" alt="Content management" />
    Inspired by the latest Web technologies and built on top of the Web parts infrastructure,
    MonoX allows you to design and develop next generation ASP.NET Web
    portals and applications. It features an intuitive, user-friendly user interface that supports Web parts framework,
    drag and drop, WYSIWYG interface, content versioning, advanced security model, cross-browser support,
    advanced templating engine and multi-level personalization.                    
        <li><a href="/MonoX/Pages/Features.aspx">>> Features</a> </li>
        <li><a href="/MonoX/Pages/AdditionalResources.aspx">>> Related resources</a> </li>
        <li><a href="/MonoX/Pages/News.aspx">>> News</a> </li>
        <li><a href="/MonoX/Pages/SocialNetworking/EventCalendar.aspx">>> Calendar</a> </li>
        <li><a href="/ContentPage/ChangeLog/">>> Change log</a> </li>                                                           

3.2 You can insert / create the document programatically by inserting records to MonoX "Document" table

Every programmatic operation can be done by using the MonoX repository layer and here are the few samples:

Create a document
DocumentRepository.GetInstance().CreateNewDocument(DefaultDocumentTitle, DefaultContent, ContentId, InstanceOfTheEditorPart, PageId)
Create a document version 2
DocumentEntity document = new DocumentEntity(GuidExtension.NewSequentialGuid());
document.RevisionVersion = false;
document.BackupVersion = false;
document.PageId = pageId;
document.ControlId = PageUtility.GetControlPersonalizationKey(editorInstance);
if (!string.IsNullOrEmpty(contentId))
    document.ContentId = contentId;
document.LanguageId = LocalizationUtility.GetCurrentLanguageId();
document.TextContent = content;
if (!GuidExtension.IsNullOrEmpty(SecurityUtility.GetUserId()))
    document.UserId = SecurityUtility.GetUserId();
document.DateModified = DateTime.Now;
document.Title = title;
DocumentRepository.GetInstance().SaveEntity(document, true);

My suggestion will be to insert the default content by parsing the file (simple string replace would do the job) because in some cases it is hard to get the instance of the editor to create the document.

I hope this will help you find the best way to accomplish the task at hand.


This content has not been rated yet. 
15993 Reputation 2214 Total posts


3/31/2011 2:02:50 PM
Now there you have given us a few new options.

Ill work trough them all, I didnt look at the document table but I just saw its pretty simple....


This content has not been rated yet. 
246 Reputation 35 Total posts