?? updatepwd.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace cms
{
/// <summary>
/// updatepwd 的摘要說明。
/// </summary>
public class updatepwd : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox Tbx_id;
protected System.Web.UI.WebControls.TextBox Tbx_beforepwd;
protected System.Web.UI.WebControls.Button Btn_update;
protected System.Web.UI.WebControls.Panel Pn_user;
protected System.Web.UI.WebControls.TextBox Tbx_newpwd;
protected System.Web.UI.WebControls.TextBox Tbx_pwdok;
protected System.Web.UI.WebControls.CompareValidator Cv_pwd;
protected System.Web.UI.WebControls.Button Btn_ok;
protected System.Web.UI.WebControls.Label Lbl_note;
protected System.Web.UI.WebControls.Panel Pnl_update;
protected System.Web.UI.WebControls.Button Btn_back;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Btn_update.Click += new System.EventHandler(this.Btn_update_Click);
this.Btn_ok.Click += new System.EventHandler(this.Btn_ok_Click);
this.Btn_back.Click += new System.EventHandler(this.Btn_back_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Btn_update_Click(object sender, System.EventArgs e)
{
Pnl_update.Visible=true;
Pn_user.Visible=false;
}
private void Btn_ok_Click(object sender, System.EventArgs e)
{
string strconn= ConfigurationSettings.AppSettings["dsn"];
SqlConnection cn=new SqlConnection(strconn);
cn.Open();
string strsql="update users set User_password='"+Tbx_newpwd.Text+"' where User_id='"+Tbx_id.Text+"'";
SqlCommand cm=new SqlCommand(strsql,cn);
try
{
cm.ExecuteNonQuery();
Lbl_note.Text="修改成功,請返回!";
}
catch(SqlException)
{
Lbl_note.Text="修改有誤!";
Pn_user.Visible=true;
}
cn.Close();
}
private void Btn_back_Click(object sender, System.EventArgs e)
{
Response.Redirect("default.aspx");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -