Hello, Friends, today’s topic is very and most important for the project and very helpful for starting beginners which are starting in doing a project in asp.net and c# language.
Friends, the most important is when we forget the password and username after registering in a website and it can be retrieved again on our own registered mail id.
Few steps are the following :
Let’s see how and what to do so that we can retrieve the forgotten username and password on our own registered email.
Friends, first of all, open Visual Studio 2012 or whatever version you have.
After that, you have to click on the FILE MENU on TOP and select NEW and click on Project Option.
After that, you have to give a name to the project by selecting the ASP.NET EMPTY WEB APPLICATION by clicking on the web option under the VISUAL c # option.
2. NEW PROJECT->VISUAL C#->WEB->ASP.NET EMPTY WEB APPLICATION
Friends, the easiest way for you is to open the first option of VIEW MENU by clicking on SOLUTION EXPLORER, after that, you have to right-click on it and you will have to click on the NEW ITEM going to the ADD option.
3. VIEW->SOLUTION EXPLORER->ADD->NEW ITEM
After clicking on ADD ITEM, you have to select WEBFORM and you can name it and if not, then it will take the name DEFAULT PAGE.
4. ADD ITEM->WEBFORM
Friends, the next step is very important, that is, without the database, we cannot store the value in the project. In ASP.NET, you can create the database by going to the View menu and clicking on the server explorer option.
5. VIEW->SERVER EXPLORER ->DATA CONNECTION->CONNECTION STRING->TABLES
public partial class forget : System.Web.UI.Page
string cs = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
protected void Button1_Click(object sender, EventArgs e)
string to = TextBox1.Text;
SqlConnection con = new SqlConnection(cs);
string query = "select name,email,password from userdata where email='" + to + "'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader sdr = cmd.ExecuteReader();
string email1 = sdr["password"].ToString();
string name1 = sdr["name"].ToString();
var fromAddress = new MailAddress("your email id", "From Name");
var toAddress = new MailAddress(to, "To Name");
const string fromPassword = "your password";
const string subject = "otp received by IRCTC";
string body = name1 + " your password is :" + email1;
var smtp = new SmtpClient
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
using (var message = new MailMessage(fromAddress, toAddress)
Subject = subject,
Body = body
Response.Write("<script>alert('your password has been sent your registered email-id.')</script>");
Label1.Text = "sorry please enter registered email-id.";
Friends, how did you find our article, you will definitely tell us through the comments, and friends, if you have any inconvenience, feel free to ask us your questions through the comment.
And our project-related posts will continue to come in easy language and soon our team will also provide you Hindi version in this post.
Hello Friends! Welcome To My webtecsolution blog
If you find any content infringes your copyright or trademark and if you want it to be removed from this Blog or replaced by your original content please email us to email@example.com
Guy’s if you want to know our latest product and latest information regarding then visit my new website:CLICK HERE