Kentico CMS 6.0 Controls

Getting started

Getting started

Previous topic Next topic Mail us feedback on this topic!  

Getting started

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

The following tutorial will show you how to display a button, that creates new news documents, on an ASPX page template using the CMSEditModeButtonAdd control:

 

1. Create a new Web form and prepare it to be an ASPX page template according to the guide found in the Using ASPX page templates topic.

 

2. Switch to its Design tab, drag and drop a CMSEditModeButtonAdd control from the toolbox onto the form and set its following properties:

 

ClassName: CMS.News

Path: /News/

 

This tells the control what type of documents it should create and sets the path to the document under which they should be added.

 

The code of the control will look like this:

 

<cms:CMSEditModeButtonAdd ID="CMSEditModeButtonAdd1" runat="server" Path="/News/" ClassName="CMS.News" />

 

3. Switch to the code behind of the page and make sure it has the following references at the beginning of the code:

 

[C#]

 

using CMS.UIControls;

using CMS.CMSHelper;

using CMS.PortalEngine;

using CMS.GlobalHelper;

 

4. Now add the following code to the Page_Load method:

 

[C#]

 

// Register edit mode buttons script

if (CMSContext.ViewMode != ViewModeEnum.LiveSite)

{

  ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ScriptHelper.EDIT_DOCUMENT_SCRIPT_KEY, ScriptHelper.EditDocumentScript);

}

 

This is necessary if you wish to use the control individually on an ASPX page template.

 

5. Save the changes to the web form. Now if you look at the page using the created template on some website in the Edit mode of CMS Desk, a button like the one in the following image will be displayed:

 

controls_clip0060

 

If you press the button, it will redirect you to the form used to create new news documents under the /News page.