protected void zhaohuimi_Click(object sender, EventArgs e) { if (zhaohuimi.Text == "忘记密码") { Label4.Text = "请输入新密码:"; Label5.Visible = true; TextBox_yanzhengma.Visible = true; zhaohuimi.Text = "确认修改"; Button_yanzhengma.Visible = true; Login.Text = "去登录"; goreg.Visible = false; } else { if (TextBox_email.Text == "") { Response.Write("<script>window.alert('没有输入邮箱');</script>"); return; } else if (TextBox_password.Text == "") { Response.Write("<script>window.alert('没有输入密码');</script>"); return; } else if (TextBox_yanzhengma.Text != (String)Session["yanzheng"]) { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "验证码不正确,请检查你的邮件"; return; } SqlConnection conn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=yijia;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); conn.Open(); SqlCommand cmd = new SqlCommand("SELECT * FROM user_info where email = '" + TextBox_email.Text.Trim() + "'", conn); SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); int x = 0; if (sdr.HasRows) { sdr.Close(); string time = DateTime.Now.ToString(); String MD5 = public_function.Md5Hash(TextBox_password.Text); SqlCommand sqlCmd = new SqlCommand("update user_info set password ='" + MD5 + "' where email='" + TextBox_email.Text + "'", conn); int rowCount = sqlCmd.ExecuteNonQuery(); conn.Close(); conn.Dispose(); Response.Write("<script>window.alert('密码修改成功,可以登录了');</script>"); } else { Response.Write("<script>window.alert('该邮箱还没有注册');</script>"); } Label4.Text = "请输入密码:"; Label5.Visible = false ; TextBox_yanzhengma.Visible = false ; zhaohuimi.Text = "忘记密码"; Button_yanzhengma.Visible = false ; Login.Text = "登录"; goreg.Visible = true ; Label1.Text = ""; } }
时间: 2024-02-14 09:14:12 浏览: 165
这是一段 C# 代码,它包含了一个名为 zhaohuimi_Click 的事件处理函数。在这个函数中,如果 zhaohuimi 这个控件的文本是 "忘记密码",那么就会执行一些操作,包括显示 Label5 和 TextBox_yanzhengma 这两个控件,以及将 zhaohuimi 的文本改为 "确认修改"。
如果 zhaohuimi 的文本不是 "忘记密码",那么就会检查用户输入的邮箱和密码,并且验证用户输入的验证码是否正确。如果验证通过,就会连接到一个数据库,并且更新该邮箱对应的用户的密码。最后,会将一些控件的状态恢复到最初的状态。
相关问题
public partial class AdminManger_AddCP : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { } } protected void Button3_Click(object sender, EventArgs e) { string res; upload up = new upload(); res = up.Up(file1, "../files/"); this.Label1.Visible = true; this.Label1.Text = up.Resup[Convert.ToInt32(res)]; this.pic.Text = up.s; Image1.ImageUrl = "../files/" + pic.Text; } protected void Button1_Click(object sender, EventArgs e) { //实例化对象 Model.CPInfo en = new Model.CPInfo(); en.SPName = title.Text.ToString().Trim(); en.SPNum = decimal.Parse(TextBox3.Text); en.SPPhoto = pic.Text; en.SPPrice = decimal.Parse(TextBox2.Text); //商品业务逻辑层 BLL.CPInfoBusiness busi = new BLL.CPInfoBusiness(); busi.Add(en); Alert.AlertAndRedirect("添加成功", "AddCP.aspx"); } }
这段代码看起来也是一个 ASP.NET 网页的代码,其中定义了一个名为 AdminManger_AddCP 的页面类,它继承了 System.Web.UI.Page 类。在页面加载时,如果不是页面回传(PostBack),则不执行任何操作。在 Button3_Click 事件中,首先实例化了一个 upload 类的对象 up,然后调用 up.Up 方法来上传文件,并将上传结果存储在 res 变量中。接着将 Label1 控件设置为可见,并将上传结果显示在 Label1 控件上,将上传文件的路径存储在 pic 变量中,并将该文件在网页上显示出来。在 Button1_Click 事件中,首先实例化了一个 Model.CPInfo 类的对象 en,并设置其属性值。然后实例化了一个 BLL.CPInfoBusiness 类的对象 busi,并调用其 Add 方法将 en 对象中的属性值添加到数据库中。最后调用 Alert.AlertAndRedirect 方法弹出提示框,提示添加成功,并跳转到 AddCP.aspx 页面。
protected void Button1. Click(object sender, EventArgs e) if (RadioButtonList1______ == _____ ) { Label1.Text =“正确"; else Label1.Text = °错误"; }
正确的代码应该是:
```
protected void Button1_Click(object sender, EventArgs e)
{
if (RadioButtonList1.SelectedValue == "正确")
{
Label1.Text = "正确";
}
else
{
Label1.Text = "错误";
}
}
```
在这个方法中,我们首先检查RadioButtonList1中选中的项的值是否等于“正确”。如果是,我们将Label1的文本设置为“正确”,否则将其设置为“错误”。注意,我们使用的是`SelectedValue`属性来获取选中项的值。
阅读全文
相关推荐

















