1 year ago

BIS 450 DeVry Week 7 iLab 8

7. Use the Enter key to

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

2. Open the BIS450 Lab8 Code Snippets.txt file that you downloaded from Doc Sharing, and select and copy the first line, “Imports System.Net.Mail”. Paste this command into the very first line of the code-behind file, above “Partial Class Signup”. 3. Return to the BIS450 Lab8 Code Snippets.txt file, select and copy the section of code beginning with the comment, “Save e-mail address to database”, and paste it into in between the Protected Sub btnSignup_Click(. . . ) and End Sub statements in the code-behind file. After pasting in this code, the code-behind file should look like this: 4. If you do not have an e-mail account that supports SMTP access, or if you choose not to use your own e-mail account to test your code, “comment out” the line smtp.Send(msg) by placing a single quotation mark (‘) at the beginning of the line, like this: ‘smtp.Send(msg) This will allow the rest of your code to work, including saving the e-mail address in the database and displaying a thankyou message to the user, without actually trying to send an e-mail. 5. Save your work on the Signup.aspx and Signup.aspx.vb files. STEP 5: Test, Capture Screenshot, and Submit. 1. To test the Newsletter Signup form, in the Solution Explorer window, right-click on Signup.aspx and select View in Browser. The form should look like this: 2. If you have an e-mail account that provides SMTP access, enter your own e-mail address into the “Enter your e-mail address:” TextBox; then enter the SMTP information for your e-mail account that you gathered in Step 2 into the fields under “For Test Only:”. Click the Sign Up for Newsletter button. The e-mail address that you entered should appear in the test GridView at the bottom of the page, and an e-mail should be sent to your account. (It may take some time for the e-mail to appear in your inbox, even if everything worked correctly). Your ability to actually send an e-mail depends on many factors, some of which are beyond your control, such as your ISP’s network configuration and restrictions imposed by your e-mail provider. This is the reality of the modern Internet, which is a complex system with many interdependent parts. On a real project, you might have to work across organizational boundaries with several different specialists, including network engineers and system administrators, to get this and other advanced Web features to work. If you are consistently getting errors thrown by the line smtp.Send(msg) in your code, and you are reasonably sure that you are entering your e-mail account information correctly, then just comment out this line by placing a single quote (‘) in front of it, and move on. The rest of your code will still work, and you will still get a thank-you message displayed and the e-mail address will still be added to the database—but no e-mail will be sent. If you do not have an e-mail account with SMTP access, or if you have chosen not to use one, you should have already commented out the smtp.Send(msg) line. If not, please do so now. Then, enter the following “dummy” information in the form: • Enter your e-mail address: • Sender’s e-mail address: • SMTP server address: • Port: 25 • Account name: test • Password: test • Use SSL/TLS: leave unchecked • Click the Sign Up for Newsletter button. 3. Capture a screenshot of the Newsletter Signup form showing the thank-you message and the e-mail address that you entered displayed in the test GridView, and paste it into a Word document. 4. Save the Word document containing your two screenshots as Your Name BIS450 Lab8 Screenshot.docx. (Make sure that the browser URL is visible in both screenshots). Submit this file to the Week 7 iLab Dropbox

DEVRY CIS 336 Week 7 iLab 7
DEVRY MGMT 404 Week 7 iLab
DEVRY BIAM 400 Week 7 iLab NEW
DEVRY BIAM 420 Week 7 iLab NEW