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 pair of buttons, that can edit or delete a specific news document, on an ASPX page template using the CMSEditModeButtonEditDelete 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 CMSEditModeButtonEditDelete control from the toolbox onto the form and set its Path property to /News/New-Consulting-Services.

 

This sets the path to the document that the control should edit or delete.

 

The code of the control will look like this:

 

<cms:CMSEditModeButtonEditDelete ID="CMSEditModeButtonEditDelete1" runat="server" Path="/News/New-Consulting-Services" />

 

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 pair of buttons as seen in the following image will be displayed:

 

controls_clip0061

 

If you press the Edit button, it will redirect you to the form used to edit the /News/Your-first-news document. If you click the Delete button, the same document  will be deleted.

 

Use in transformations

 

If you wish to use this control in the code of a transformation, you can do so by adding code similar to the following:

 

<cms:CMSEditModeButtonEditDelete runat="server" id="btnEditDelete" Path='<%# Eval("NodeAliasPath") %>' />

 

The path will automatically be set to that of the currently transformed document.