Ektron CMS400.NET API Documentation
|
Method to obtain a particular forum by ID. Returns a discussion board with a 1 length Discussion Forum array. If the forum does not exist, then a DiscussionBoard with a zero length Forums property will be returned.
See Also: The Example section.
public DiscussionBoard GetForum(Long forumid);
Public Function GetForum(ByVal forumid As Long) As DiscussionBoard
Parameters |
Description |
forumid |
Numeric value of the forum ID. |
An instance of type DiscussionBoard.
The following example shows how to create a Web page from which forum data can be retrieved. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetForum method. This method uses the InternalAdmin to retrieve the forum data. 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 a label with the following information. <asp:Label ID="Label1" runat="server" Text="Forum ID: "></asp:Label> 2. Add a text box to enter the Forum ID. <asp:TextBox ID="txtForumId" runat="server" Width="63px"></asp:TextBox> 3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Forum ID Box. <asp:RequiredFieldValidator ID="rfvForumId" runat="server" ControlToValidate="txtForumId" ErrorMessage="Please enter forum ID"></asp:RequiredFieldValidator> 4. Add a couple of breaks for spacing purposes. <br /><br /> 5. Add a button, to retrieve the forum data. <asp:Button ID="btnGetForum" runat="server" Text="Get Forum" Width="72px" /> 6. Add a couple of more breaks for spacing purposes. <br /><br /> 7. Add a results label where the forum data will appear. This label is also used to display any errors that might occur. <asp:Label ID="lblResult" runat="server" Width="604px" Height="113px"></asp:Label>
Add the following information to the code behind of your aspx.vb page.
Protected Sub btnGetForum_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetForum.Click
Dim board As New Ektron.Cms.DiscussionBoard Dim forumApi As New Ektron.Cms.API.Content.ThreadedDiscussion
If Not IsNumeric(txtForumId.Text) Then lblResult.Text = "Invalid Forum ID" Exit Sub End If
Try board = forumApi.GetForum(CInt(txtForumId.Text))
If (board.Id = 0) Or (board.Forums.Length <> 1) Then lblResult.Text = "Error getting forum" Exit Sub End If
lblResult.Text = "Board Title: " & board.Title & "<br/>" lblResult.Text &= "Board Name: " & board.Name & "<br/>"
lblResult.Text &= "Forum Category: " & board.Forums(0).CategoryName & "<br/>" lblResult.Text &= "Forum Name: " & board.Forums(0).ForumName & "<br/>" lblResult.Text &= "Forum Title: " & board.Forums(0).ForumTitle & "<br/>" lblResult.Text &= "Number of topics: " & board.Forums(0).NumberofTopics & "<br/>" lblResult.Text &= "Number of posts: " & board.Forums(0).NumberofPosts & "<br/>"
Catch ex As Exception lblResult.Text = ex.Message End Try End Sub
Copyright (c) 2008. All rights reserved.
|
What do you think about this topic? Send feedback!
|