10.1. Using Profiles
You want to make use of user profile data throughout your application without having to implement the infrastructure yourself.
Use the ASP.NET 2.0 membership and profile features by implementing the membership features described in Recipe 9.5, modify web.config to enable user profiles, define in web.config the specific user data to include in the profile, provide the ability to update the user profile data, and use the data as required in your application.
Modify web.config as follows:
<profile>element with a
<provider>element defining the provider used to store and retrieve user-specific data.
<properties>element and an
<add>element for each user-specific data item to be included in the profile.
In the .aspx file for the page used to enter the user-specific data:
Add a server control for each user-specific data item.
Add an Update button (or equivalent) to initiate the updating of the user-specific data.
In the code-behind class for the page used to enter user-specific data, use the .NET language of your choice to:
Initialize the controls in the .aspx file with the current data from the user’s profile.
Implement an event handler for the Update button click event and update the user’s profile from the data entered by the user.
The solution we have implemented to demonstrate the solution is shown in Examples 10-1, 10-2, 10-3 through 10-4. Example 10-1 shows the modifications made to web.config. Example 10-2 shows the .aspx file used to enter ...