BIS 450 DeVry Week 7 I Lab 8
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
7. Use the Enter key to move to the next line on the form. Drag an AccessDataSource control from the Data section of<br />
the Toolbox onto the web form. Click on the Configure Data Source task in the control’s smart tag and configure the<br />
data source as we did in i<strong>Lab</strong>s 4 and 5, using the following settings:<br />
• Microsoft Access data file: database/HealthyEating.mdb<br />
• Specify columns from a table or view (Name: Subscribers)<br />
• Columns: Check SubscriberID and Email<br />
• No WHERE clause is needed<br />
• Click the Advanced button and check the box to generate INSERT, UPDATE, and DELETE statements.<br />
• There is no data in the table, so you will not retrieve any records if you test your query.<br />
8. You will need to edit the automatically generated SQL INSERT statement. With the AccessDataControl still selected,<br />
click the InsertQuery property, then click the […] button. Edit the INSERT command so that it reads as follows:<br />
INSERT INTO [Subscribers] ([Email]) VALUES (?)<br />
Then, in the Parameters box, select the SubscriberID parameter and click the red X button to delete it. The final<br />
definition of the INSERT command should look like this:<br />
Click OK.<br />
(These changes are necessary because in the database table, SubscriberID is an AutoNumber field whose value is<br />
supplied by the database, not by the INSERT command).<br />
9. On the line below the AccessDataSource control, type the heading For Test Only:. Then on the following lines, type<br />
these prompts followed by the corresponding controls:<br />
Prompt Control (ID) Text<br />
Sender’s Email Address: TextBox txtSenderEmail<br />
SMTP Server Address: TextBox txtSMTPAddress<br />
Port: TextBox txtPort<br />
Account Name: TextBox txtUsername<br />
Password: TextBox txtPassword<br />
Checkbox chkSSL Use SSL/TLS<br />
Also, set the TextMode property of the txtPassword TextBox to Password. This will cause your password to be masked<br />
when you enter it.<br />
TIP: You will use these controls to enter the information for your SMTP-capable e-mail account when you test your<br />
code. Of course, if this were a real project, in the final version, these values would not be entered on the form by a<br />
user. Most likely, they would be saved in the Web.config file (as you did the administrator log-in information in an earlier<br />
lab). It is often convenient to put in temporary features like these ones for use during development and testing. Just be<br />
sure, on a real project, to remove them before going live with the site!<br />
10. Also, for test purposes only, drag a GridView control from the Data section of the Toolbox and drop it on the form<br />
just below the controls that you added in the previous action. Set the GridView’s data source to AccessDataSource1.<br />
This will allow you to see the contents of the newsletter subscriber list in the database, so you can confirm that your<br />
code to add an e-mail address to the database is working.<br />
Your completed form should look like this in Design View:<br />
11. Save your work on the Signup.aspx form.<br />
STEP 4: Add Code to Save E-mail Addresses and Send Confirmation.<br />
1. Double-click the btnSignup button to create a skeleton click event handler procedure in the code-behind file.