Datasheet

This step creates a new diary for users and stores their first and last names. The UserName comes from
the
CreateUserWizard control’s UserName property, and then uses the shared method InsertDiary()
to insert the new user in the Online Diary’s database.
Being human, sometimes people forget their passwords. Fortunately, ASP.NET 2.0 comes with the capa-
bility to refresh overloaded memories.
Password Reminder
Again with virtually no code, you can create a fully functional password reminder feature for the Online
Diary, this time courtesy of the
PasswordRecovery control. Virtually all of its settings are at the default
values or simply related to style. Even better, there’s just one line of code and that’s in the
SendingMail
event:
Protected Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.MailMessageEventArgs) Handles
PasswordRecovery1.SendingMail
returnToLogOnHyperLink.Visible = True
End Sub
The SendingMail event fires when the user presses the Send Email button and simply displays the
Return to Main Page link, rather than leaving the user guessing as to where to go next.
The main work involved is configuring the SMTP server settings that’ll be used to actually send the
password reminder e-mail. Visual Web Developer doesn’t come with an SMTP server. However, if you
are using Windows XP or 2000, all you need to do to install one is go to the StartSettingsControl
PanelAdd or Remove Programs. From there, select Add/Remove Windows Components. Select the
Internet Information Server (IIS) option and click Details at the bottom-right of the dialog. In the result-
ing dialog box, you’ll see a list. Check the box next to SMTP Service and click OK. Then click Next to
install an SMTP service.
Once the SMTP service is installed, add the following shaded code between the
<configuration> tags
in the Web.config file:
<configuration xmlns=”http://schemas.microsoft.com/.NetConfiguration/v2.0”>
<connectionStrings>
<add name=”DiaryDBConnectionString” connectionString=”Data
Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\DiaryDB.mdf;Integrated
Security=True;User Instance=True”
providerName=”System.Data.SqlClient” />
</connectionStrings>
<system.web>
<roleManager enabled=”true” />
<authentication mode=”Forms”/>
<compilation debug=”true”/></system.web>
<system.net>
<mailSettings>
<smtp from=”system@diary-system.com”>
<network host=”localhost” password=”” userName=”” />
</smtp>
</mailSettings>
</system.net>
</configuration>
23
The Online Diary and Organizer
04_749516 ch01.qxp 2/10/06 9:11 PM Page 23