aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Change user password using changepassword control in membership provider

Jan 8, 2012

In this article I will explain
how to use changepassword control to change password in membership provider.


In previous posts I explained clearly how to create users using createuserwizard or programmatically create users using membership and I explained  how to get forgot password through email. In previous post Get forgot password through mail it will reset our password and sent randomly generated new password through mail. It’s very hard to remember randomly generated password. If we allow users to change their passwords directly that is very convenient. We can achieve this one easily by using changepassword control membership. 

changepassword control allows currently logged in users to change their password. If we want to change another user password then it’s not possible because every time it will take only currently logged in user. 

If we want change password for other users we need to set property DisplayUserName= "True" in changepassword control (right click on changepassword >> change DisplayUserName="True"). It will add other control UserName in changepassword before set DisplayUserName property it contains only 3 controls those are old password, new password, confirm new password.

Now open your aspx drag and drop changePassword control from Login Controls section after that our page code will be like this  

<html xmlns="">
<head runat="server">
<title>Change Password</title>
<form id="form1" runat="server">
<asp:ChangePassword ID="ChangePassword1" runat="server" DisplayUserName="True">
Here don’t forgot to set database connection settings in web.config 

Write the following code in system.web section

<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="dbconnection" applicationName="SampleApplication"/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="dbconnection" applicationName="SampleApplication"/>
<roleManager enabled="true">
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="dbconnection" applicationName="SampleApplication"/>
Now run your application and enter username, old password and new password after successful change of password we will get success message.


If you want send mail after successful change of password we need to set the smtp server configurations (<>) in web.config file of configuration section. If you don’t know how to set then check this post Recover forgot password in

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


Nazmul Hossain said...
This comment has been removed by the author.
Anonymous said...


saikumar... said...

Nice Post Brother.............keep on going

Anonymous said...

How do i make it work with my custom database structure?

Anonymous said...

Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The configuration section cannot contain a CDATA or text element.

Source Error:

Line 50:
Line 51: "/>
Line 53:
Line 54:

Anonymous said...

Hello Sir,

I liked your article. But i have to do the same but without using membership. can you please explain me how to do this or give some related article?

birkin said...

Hi, this is a useful expert issue.

Anonymous said...

Nice post

Unknown said...

where is system.web section in

Anonymous said...

Hi suresh,

I want to change password by using table in my Data...Please tell me how can i ?

Anonymous said...

how to handle the Password incorrect or New Password invalid. New Password length minimum: 6. Non-alphanumeric characters required: 0. in javscript sir

Anonymous said...

how to create a rdlc report where 100 columns depending on user selection need to show in report

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.