650 Chapter 13 • Creating a Message Board with ADO and XML
other pages, there is a validation control for every text box to make sure the user enters the required information. Let’s take a look at the code-behind for this form in Figure 13.72.
Figure 13.72 The Code-Behind (Createboard.aspx.vb)
Private Sub Page_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load 'only logged-in admins can enter this page
If Me.IsLoggedIn = False Then
Response.Redirect("default.aspx")
ElseIf Me.CurrentUser.IsAdmin = False Then
Response.Redirect("default.aspx")
End If
End Sub
Private Sub btnCreate_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnCreate.Click
If Me.IsValid = True Then
'create the new board
dotBoardObjects.Board.CreateBoard(txtBoardName.Text, _ txtBoardDescription.Text, _
Me.CurrentUser)
Response.Redirect("default.aspx")
End If
End Sub
Like every other admin page so far, this page guarantees that the current user is a logged-in administrator, and if not, redirects to the default page. After the user has entered the required information to create a board and clicks the Create Board button, the btnCreate_Click method is called. First, the method checks to make sure the page is valid, then it creates the board based on the values the administrator entered. Finally, it redirects the administrator back to the default page so he can see his newly created board.
The last things an administrator should be able to do are delete Boards, Threads, and Posts.This functionality can be placed on the appropriate pages