482 Chapter 11 • Creating an XML.NET Guestbook
Figure 11.4 Continued
52:</asp:Panel>
53:</body>
54:</html>
It may look daunting at first, but it really is quite simple. Remember that in ASP.NET you first should declare the language the page is going to be using. While it is redundant, since the language declaration on the <script> tag determines the actual language use, it is still a good coding practice to get into. Lines 2 through 4 declare the namespaces that you are going to use—System, System.IO, and System.Data. Lines 5 through 8 just display the HTML code that needs to be in every single HTML page.
You then hit the script tag that controls the Submit button event (lines 9 through 10). For now it’s just a placeholder for the code you’ll be adding in later. Notice that the code is placed at the head of the html file, which means that it will be processed before anything else.You’ll look at the Submit button event after you dissect this portion of the ASP.NET page.
Understanding the pnlAdd Panel
On line 19 of Figure 11.4, pnlAdd is declared; it is the name of the panel that contains the programming code displaying the messages and text boxes that the user will be viewing on the page, in order to enter the guestbook entry data; e.g., the name area, the name entry textbox, the e-mail area, the e-mail entry textbox, the comment area, the comment entry textbox, and the Submit button. In other words, it is your run-of-the-mill HTML form but with ASPX. In reality there are only two “normal” form objects; the name textbox is your standard text object, and the comment area is your standard multilane textbox.
The e-mail area, however, is another story.Take a look at the behemoth of a line that you’ll find in line 32:
<asp:textbox text="" id="Email" runat="server"/
><asp:RequiredFieldValidator ControlToValidate=Email display=static
runat=server> *</asp:RequiredFieldValidator>
<asp:RegularExpressionValidator runat="server"
ControlToValidate="Email"
ValidationExpression="[\w-]+@([\w-]+\.)+[\w-]+"
Display="Static"