Friday, April 18, 2008

Simple Code for Forgot Password

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data .SqlClient;

public partial class Forgotpwd : System.Web.UI.Page
{
SqlConnection scn = new SqlConnection("Data source=.;Initial Catalog=Routingmail;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
TextBox1.Text = Session["userid"].ToString();
if (scn.State == ConnectionState.Closed)
{
scn.Open();
}

SqlCommand cmd = new SqlCommand("Select secquestion from registration where userid='"+TextBox1.Text+"'",scn);
string str = Convert.ToString(cmd.ExecuteScalar());
txtsecuriy.Text = str;
}

}
protected void Button1_Click(object sender, EventArgs e)
{
scn.Open();
SqlCommand cmd = new SqlCommand("select pwd from registration where answer='" + txtanswer.Text + "'", scn);
String str = Convert.ToString(cmd.ExecuteScalar());
Label1.Text = "your password is " + str;
Label1.Visible = true;
scn.Close();
}

}

No comments:

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...