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

Delete the folder by its ID. 

See Also: The Example section.  

C#
public Boolean DeleteFolderById(Long Id);
Visual Basic
Public Function DeleteFolderById(ByVal Id As Long) As Boolean
Parameters 
Description 
Id 
The folder's ID. 

False = successfully deleted. Otherwise, returns True.

The following example shows how to create a Web page from which a folder can be deleted from CMS400.NET by entering its ID. This example uses some standard drag and drop controls and a small section of VB code utilizing the DeleteFolderById method. This method uses the InternalAdmin to delete 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 ID: "></asp:Label>
  2. Add a text box to enter the folder's ID.
       <asp:TextBox ID="txtFolderId" runat="server" Width="44px"></asp:TextBox>
  3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Folder ID box.
       <asp:RequiredFieldValidator ID="rfvFolderId" runat="server" ControlToValidate="txtFolderId"
           ErrorMessage="Please enter folder ID"></asp:RequiredFieldValidator>
  4. Add a couple of breaks for spacing purposes.
       <br /><br />
  5. Add a delete button. We will set the button click event in the code behind.
       <asp:Button ID="btnDeleteFolder" runat="server" Text="Delete Folder" Width="95px" /> 
  6. Add two more breaks for spacing purposes.
       <br /><br />
  7. Add a label to let the user know if the delete succeeded.
       <asp:Label ID="lblResult" runat="server" Width="346px"></asp:Label>

 

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

  1. Add a button click event.

        Protected Sub btnDeleteFolder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDeleteFolder.Click

  1. Check to make sure the folder ID entered is numeric.

             If Not IsNumeric(txtFolderId.Text) Then
                 lblResult.Text = "Invalid Folder ID"
                 Exit Sub
             End If       

  1. Create an object for the Folder API.

             Dim folderApi As New Ektron.Cms.API.Folder

  1. Create a Try/Catch around the DeleteFolderById method. This allows you to catch any exceptions and helps when debugging.

             Try
                 folderApi.DeleteFolderById(CInt(txtFolderId.Text))

  1. Display whether the deletion was successful.

                 lblResult.Text = "The above folder was deleted from CMS400.NET"

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

               Catch ex As Exception
                   lblResult.Text = "Error deleting folder"
               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!