Database Storage with the ASP.NET Web Matrix - Setting up a registration page
(Page 3 of 6 )
Now let’s set up a registration page that will let users enter their username and password into a form that will insert their details into the logins table.
Choose the New File button, highlight the ASP.NET Page template from the General Selection, and change the filename to something appropriate. When the blank page loads, the Web Controls toolbox will be open by default. From this toolbox, drag a label and a textbox onto the page. Select the label, and in the properties pane on the right-hand side click into the Text value field. Set the text to Username: and press return.
Now select the textbox, and this time in the Properties pane, select the ID field value and enter txtUsername. Using a prefix denoting the control type of the element and a meaningful name are standard practice in object oriented programming. On this type of page it really makes little difference what the working elements of the page are called, but if you created a page with twenty text boxes on it, how useful would the ID TextBox15 be? With the textbox still selected, press the right arrow key on the keyboard and then press return to get to the next line.
Drag another label and textbox onto the page and set the Text and ID values to Password and txtPassword, then repeat the process once more and set the values to Verify Password: and txtPassword respectively. It is standard practice on a registration page to check that the visitor knows for sure what the password is being set to. When the two password boxes are different, you need to tell the visitor somehow without running the database INSERT function. Add another label directly after the verify password text box and remove the default Text value. Set the ID to lblPasswordError and chose a foreground colour of red. This label will appear enclosed in square brackets on the design page to show that it has no text value.
Go to a new line again and drag two button controls onto the page; set the ID of the first button to btnSubmit and the Text to Submit. Now set the ID to btnClear and the Text to Clear.

Next: Coding the page >>
More Database Articles
More By Dan Wellman