Attention: We are retiring the ASP.NET Community Blogs. Learn more >

User profile

Well this time I am going to show how to save values in user profile with asp.net membership provider.

- first we have to decide what we want to save in our users profile let's say first name, last name and telephone number.

To achive this task we have to define in the web.config file a few keys, and the type of information that they will care off:

<profile enabled="true">

<properties>

<add name="FirstName" type="System.String"/>

<add name="LastName" type="System.String"/>

<add name="PhoneNumber" type="System.String"/>

</properties>

</profile>

Good, now its time to work little bit in aspx file and to get the values from our users:

<asp:Lable ID="lblFirstName" runat="server" Text="First name: " /><asp:TextBox ID="tbFirstName" runat="server" />

<br />

<asp:Lable ID="lblLastName" runat="server" Text="Last name: " /><asp:TextBox ID="tbLastName" runat="server" />

<br />

<asp:Lable ID="lblPhoneNumber"  runat="server" Text="Phone: " /><asp:TextBox ID="tbPhoneNumber" runat="server" />

<br />

<asp:Button ID="btnSubmit"  runat="server" Text="Submit to profile" />

Ok, we now have all we need to save some info in our profile, so lets go to the essential part (the code-behind):

Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSubmit.Click

Profile.FirstName = tbFirstName.Text

Profile.LastName = tbLastName.Text

Profile.PhoneNumber = tbPhoneNumber.Text

Profile.Save()

End Sub

Well thats it hope it helps

 

P.S. You can use it in customer step while users registration

1 Comment

Comments have been disabled for this content.