Hi Fiends ! Today ,I am going to explain "How to change password in asp.net website with example".If you are managing an asp.net website then you have to add this page on your website.It is simple and easy process. If you have built registration and login page on website then you have to add this page on your website, Because every registered users want to change your password for security purpose.if you add this page on your website then any registered user can easily change your password and secure your valuable data.
I have already built a registration and login page in our previous post.Some students wanted this change password page so i am going to add this page in our previous registration and login page. Now days ,Google ,Yahoo,Facebook ,Microsoft and other websites are using this functionality for security purpose.
I have build this page in separate post.you can add this page on your existing registration page by the copy and paste function.
There are some steps to implement this concepts on asp.net website as given below:-
Step 1 :- First open your visual studio -->File -->New -->Select ASP.NET Empty website -->OK-->Open Solution Explore -->Add a New Web Form (login.aspx) -->Drag and Drop Label,Text Box ,Button ,SqlDataSource and validation control on the form from toolBox as shown below:-
Step 2 :- Now Open Your Solution Explorer --> Add a Database.mdf file -->create a table such as cust_details with required column as shown below:-I have already built a registration and login page in our previous post.Some students wanted this change password page so i am going to add this page in our previous registration and login page. Now days ,Google ,Yahoo,Facebook ,Microsoft and other websites are using this functionality for security purpose.
I have build this page in separate post.you can add this page on your existing registration page by the copy and paste function.
There are some steps to implement this concepts on asp.net website as given below:-
Step 1 :- First open your visual studio -->File -->New -->Select ASP.NET Empty website -->OK-->Open Solution Explore -->Add a New Web Form (login.aspx) -->Drag and Drop Label,Text Box ,Button ,SqlDataSource and validation control on the form from toolBox as shown below:-
Note:-Here you can take help for adding the .mdf database file on website.
Step 3 :- Now Right Click on Cust_details table --> Show Table Data -->You will see the all registered candidate's data as shown below:-
Step 4 :- Now configure SqlDataSource with table(cust_details)-->Click SqlDataSource --> Configure Data Source -->Select Database.mdf --> Next --> create My_ConnectionString---> Proceed with Next Button -->Finish-->done.
Step 5 :- Now write the following c# codes in login.aspx.cs page(login button click) as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select COUNT(*)FROM cust_details WHERE name='" + TextBox1.Text + "' and pass='" + TextBox2.Text + "'");
cmd.Connection = con;
int OBJ = Convert.ToInt32(cmd.ExecuteScalar());
if (OBJ > 0)
{
Session["name"] = TextBox1.Text;
Response.Redirect("Change_Password.aspx");
}
else
{
Label1.Text = "Invalid username or password";
}
}
}
Step 6 :- Now open Solution Explorer -->Add a New Web Form (change_password.aspx) --> Drag and Drop Label,TextBox ,Button ,Required field validator and Compare validator on the form as shown below:-
Note :-
- First you need to validate each Text Box Control with each validation control.You have to more about Validation controls in asp.net.
Step 7 :- Now Write the all c# codes in change_password.aspx.cs page (Submit button click) as given below:-
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;
public partial class Change_Password : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label2.Text = "Welcome " +Session["name"].ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString);
con.Open();
string str1 = "select * from cust_details where pass ='" + TextBox1.Text + "'";
SqlCommand cmd = new SqlCommand(str1, con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read())
{
SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["My_ConnectionString"].ConnectionString);
con1.Open();
string str = "update cust_details set pass='" +TextBox2.Text+ "'where pass= '"+TextBox1.Text+"'";
SqlCommand cmd1 = new SqlCommand(str, con1);
cmd1.ExecuteNonQuery();
Label1.Text = "Your Password has been changed successfully ";
con1.Close();
con.Close();
}
else
{
Label1.Text = " Your old Password is incorrect try again... ";
}
}
}
Step 8 :- Run the Application (press F 5) -->Enter required loin deatails as shown below:--->Press Logon Button:-
Step 9 :- Now Enter Required field details on change_password page -->press Submit Button as shown below:-
Note:-
- Here user can't blank any Text Box Field.
- Both New password field Should be same otherwise it will show an error message.
- Old password should be correct otherwise you can not change the password.
Note:-
- If your password have been changed then you can login in application with New Password without any problem.
- You can see your old password value in Step 3.
- How to build Form filling application like ibps website
- How to implement trigger concepts in sql server
- How to install ajax Toolkit in asp.net website with example
- How to save image in database and save in picture box control
- How to implement cookie concepts in asp.net website
- How to copy data from one table to another table easily
- How to implement join concepts in sql server
- How generate captcha image in new way in asp.net
- How to implement exception handling concepts in c#
- Difference between delete and truncate statement
- How to implement out parameter concepts in c#
- How to make ado.net real application
Please share this application if this helpful for you.
Download Whole Attached file
Download
Thanks:- Ramshanker sir
ReplyDeleteRealy this site is very helpful ............................
Sir..........
ReplyDeleteI've a question. How to convert audio file to text file in windows application c# or VB 2010 Please explain step by step with code.
Thanks and Regards Ram Jha
Read below link:-
Deletehttp://www.codeproject.com/Articles/380027/Csharp-Speech-to-Text
Thanks........Sir
Deleteall contains helpfull can u help me how convert vedio in audio...
ReplyDeleteRealy very usefull.. THANKS.
ReplyDeleteSir i want to send confirmation code SMS in asp.net C# website how it can be done please replay my question
ReplyDeleteSir i want to send confirmation code SMS in asp.net C# website how it can be done please replay my question
ReplyDeleteIt's very usefull..
ReplyDeleteTHANKS.
thanks man..... it really works... save me a lot of trouble...
ReplyDeletevery helpful.... thanks man... save me a lot of trouble...
ReplyDelete