Ektron CMS400.NET API Documentation
|
Loads all the subfolders for a given folder ID.
See Also: The Example section.
public FolderData[] GetChildFolders(Long id, Boolean recursive, EkEnumeration.FolderOrderBy orderBy);
Public Function GetChildFolders(ByVal id As Long, ByVal recursive As Boolean, ByVal orderBy As EkEnumeration.FolderOrderBy) As FolderData()
Parameters |
Description |
id |
The folder's ID |
recursive |
True = recursive look up. False = none. |
orderBy |
Field to order results by. |
Ektron.Cms.FolderData()
The following example shows how to create a Web page from which a folder ID can be entered and list of child folders returned. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetChildFolders method. This method uses the InternalAdmin to retrieve the child folder list. 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 submit button. We will set the button click event in the code behind. <asp:Button ID="btnGetChildFolders" runat="server" Text="Get Child Folders" Width="123px" /> 6. Add two more breaks for spacing purposes. <br /><br /> 7. Add a label to display the list of child folder names. <asp:Label ID="lblResult" runat="server" Width="272px"></asp:Label>
Add the following information to the code behind of your aspx.vb page.
Protected Sub btnGetChildFolders_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetChildFolders.Click
Dim folderApi As New Ektron.Cms.API.Folder
If Not IsNumeric(txtFolderId.Text) Then lblResult.Text = "Invalid Folder ID" Exit Sub End If
Dim folders As Ektron.Cms.FolderData()
Try folders = folderApi.GetChildFolders(CInt(txtFolderId.Text), True, FolderOrderBy.Name)
If (folders Is Nothing) Then lblResult.Text &= "Child folders: None"
Else
lblResult.Text &= "Child folders: " & folders.Length.ToString & "<br/>"
Dim i As Integer For i = 0 To folders.Length - 1 Step 1 lblResult.Text &= folders(i).Name & "<br/>" Next End If
Catch ex As Exception lblResult.Text = "Error getting child folders" End Try End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load lblResult.Text = "" End Sub
Copyright (c) 2008. All rights reserved.
|
What do you think about this topic? Send feedback!
|