Database Storage with the ASP.NET Web Matrix: Update Page
(Page 1 of 4 )
If you’ve been following this mini-series so far, you’ll know that we only have one basic database operation left to explore. We have looked at inserting, reading and removing data from a database table, all we need to do now is update our data. You’ll find that there are elements from nearly every page we have created so far in the updating page, even just a simple password update.
To get started then, we need to build the visual elements of the page. Open the Web Matrix, and in design view drag the following elements from the web controls toolbox onto the page: on the first line drag a label, a textbox and another label. Onto the second and third lines, drag the same elements, then below these, drag a button onto the page. Finally, drag another label to the line below the button.
Obviously, you need to edit some of the properties of these elements. If you didn’t already know, this is done in the Properties pane at the left-hand side of the document window. First, set the text of the first label to Username: and then select the first textbox and set the ID to txtUsername. Now select the label element following the textbox and set the ID to lblUsernameError, the Fore color to Red and clear the Text value.
On the second line, set the Text of the first label to New Password:, set the textbox ID to txtNewPassword, and set the ID of the second label to lblNewPasswordError. Then set the fore color to Red and clear the Text value. Follow this format for the third line of the page, but set the Text to Verify New Password: and the ID values to txtVerifyNewPassword and lblVerifyNewPasswordError respectively. Additionally, as the bottom two textboxes will contain passwords, you should set the TextMode property to Password to make the contents hidden when the page is used. The button ID can be set to btnUpdate, while the Text value can be Update. Finally, the label element on the last line should have the following properties: an ID of lblSuccess, a fore color of Green and an empty Text value.
Next: Important Details and Updates >>
More ASP.NET Articles
More By Dan Wellman