You are here: Ektron Namespace > .NET Assemblies > Ektron.Cms.API Namespace > Classes > Folder Class > Folder Methods > AddFolder
Ektron CMS400.NET API Documentation
ContentsIndexHome
PreviousUpNext
Folder.AddFolder Method

Creates a new folder in the CMS. By default the new folder inherits subscription properties of parent folder. To override, use the BreakInheritance property of the FolderRequest.SubscriptionProperties object (set it to True). 

See Also: The Example section.  

C#
public AddFolder(FolderRequest request);
Visual Basic
Public Sub AddFolder(ByVal request As FolderRequest)
Parameters 
Description 
request 
The Folder's properties as a FolderRequest object. 

The following example shows how to create a Web page from which a folder can be added to CMS400.NET. This example uses some standard drag and drop controls and a small section of VB code utilizing the AddFolder method. This method uses the InternalAdmin to add the folder. In the first section, we will deal with the standard drag and drop controls. In the second, we'll deal with the code behind. 

 

  1. Between the form tags, add the following label:
       <asp:Label ID="Label1" runat="server" Text="Folder Name: " Width="84px"></asp:Label>
  2. Add a text box to enter the folder's name.
       <asp:TextBox ID="txtFolderName" runat="server" Width="96px"></asp:TextBox>
  3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Folder Name box.
       <asp:RequiredFieldValidator ID="rfvFolderName" runat="server" ControlToValidate="txtFolderName"
           ErrorMessage="Please enter folder name"></asp:RequiredFieldValidator>
  4. Add a couple of breaks for spacing purposes.
       <br /><br />
  5. Add a label for the description box.
       <asp:Label ID="Label2" runat="server" Text="Description: " Width="72px"></asp:Label>
  6. Add a text box to enter a description.
       <asp:TextBox ID="txtDescription" runat="server" Width="358px"></asp:TextBox>
  7. Add two more breaks for spacing purposes.
       <br /><br />
  8. Add a button to submit the information. We will set the button click event in the code behind.
       <asp:Button ID="btnAddFolder" runat="server" Text="Add CMS Folder" Width="110px" />
  9. Add two last breaks.
       <br /><br />
 10. Add a results label that lets a user know if the add succeeded.
       <asp:Label ID="lblResult" runat="server" Width="545px"></asp:Label>

 

Add the following information to the code behind of your aspx.vb page.

  1. Add a button click event.

        Protected Sub btnAddFolder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddFolder.Click

  1. Create an object for the Folder API.

               Dim folderApi As New Ektron.Cms.API.Folder

  1. Create a Try/Catch around the AddFolder method. This allows you to catch any exceptions and helps when debugging.
  2. Create a FolderRequest object and assign the following properties:

               Try
                   Dim req As New Ektron.Cms.FolderRequest
                   req.FolderName = txtFolderName.Text
                   req.FolderDescription = txtDescription.Text
                   req.ParentId = 0  'Add this folder under the root folder in the Workarea
                   req.StyleSheet = ""
                   folderApi.AddFolder(req)

  1. Display the folder name and ID and the fact that it was added.

                   Dim newFolderID As Integer = req.FolderId
                   lblResult.Text = "Folder " & txtFolderName.Text & " was added under the root folder in the Workarea with FolderID = " & newFolderId.ToString()

  1. If there is an error, let the user know what happened.

               Catch ex As Exception
                   lblResult.Text = ex.Message
               End Try
    
     End Sub
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at [email protected].
Copyright (c) 2008. All rights reserved.
What do you think about this topic? Send feedback!