The following example shows how to create a Web page from which a forum can be added to a discussion board. This example uses some standard drag and drop controls and a small section of VB code utilizing the AddForum method. This method uses the InternalAdmin to add the forum. 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. In the Web form, create a table with four rows and three columns. 2. In the first row, first column, add the following label: <asp:Label ID="Label1" runat="server" Text="Board Id: "></asp:Label> 3. In the first row, second column, add a text box to enter the board ID. <asp:TextBox ID="txtBoardId" runat="server" Width="63px"></asp:TextBox> 4. In the first row, third column, add a RequiredFieldValidator control. This validates that something appears in the board ID box. <asp:RequiredFieldValidator ID="rfvBoardId" runat="server" ControlToValidate="txtBoardId" ErrorMessage="Please enter board ID"></asp:RequiredFieldValidator> 5. In the second row, first column, add the following label: <asp:Label ID="Label4" runat="server" Text="Forum name: " Width="80px"></asp:Label> 6. In the second row, second column, add a text box to enter the forum name. <asp:TextBox ID="txtForumName" runat="server" Width="254px"></asp:TextBox> 7. In the second row, third column, add a RequiredFieldValidator control. This validates that something appears in the Forum Name box. <asp:RequiredFieldValidator ID="rfvForumName" runat="server" ErrorMessage="Please enter forum name" ControlToValidate="txtForumName"></asp:RequiredFieldValidator> 8. In the third row, first column, add the following label: <asp:Label ID="Label7" runat="server" Text="Description:" Width="76px"></asp:Label> 9. In the third row, second column, add a text box to enter a description. <asp:TextBox ID="txtDescription" runat="server" Width="253px"></asp:TextBox> 10. In the third row, third column, add a RequiredFieldValidator control. This validates that something appears in the description box. <asp:RequiredFieldValidator ID="rfvDescription" runat="server" ErrorMessage="Please enter forum description" ControlToValidate="txtDescription" Width="186px"></asp:RequiredFieldValidator> 11. In the fourth row, first column, add the following label: <asp:Label ID="Label2" runat="server" Text="Category ID: " Width="76px"></asp:Label> 12. In the fourth row, second column, add a text box to enter a Category ID. <asp:TextBox ID="txtCategoryId" runat="server" Width="75px"></asp:TextBox> 13. In the fourth row, third column, add a RequiredFieldValidator control. This validates that something appears in the Category ID box. <asp:RequiredFieldValidator ID="rfvCatId" runat="server" ErrorMessage="Please enter category Id" ControlToValidate="txtCategoryId"></asp:RequiredFieldValidator> 14. After the table, add a couple of breaks for spacing purposes. <br /><br /> 15. Add a button, to submit the information. <asp:Button ID="btnAddForum" runat="server" Text="Add Forum" Width="72px" /> 16. Add a couple of more breaks for spacing purposes. <br /><br /> 17. Add a results label that will let the person using the page know whether or not the add succeeded. <asp:Label ID="lblResult" runat="server" Width="549px" Height="25px"></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 btnAddForum.Click
Dim board As New Ektron.Cms.DiscussionBoard Dim forumApi As New Ektron.Cms.API.Content.ThreadedDiscussion Dim forumID As long
If Not IsNumeric(txtBoardId.Text) Then lblResult.Text = "Invalid Board ID" Exit Sub End If
If Not IsNumeric(txtCategoryId.Text) Then lblResult.Text = "Invalid Category ID" Exit Sub End If
Try forumID = forumApi.AddForum(CInt(txtBoardId.Text), txtForumName.Text, txtDescription.Text, False, False, 1, CInt(txtCategoryId.Text))
If (forumID <> 0) Then lblResult.Text = "Forum added to the board with Forum ID = " & forumID End If
Catch ex As Exception lblResult.Text = ex.Message End Try End Sub