⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getpassword.aspx.cs

📁 This is not a very mean things
💻 CS
字号:
//-----------------------------------------------------------------------
//
// WebExpert.NET 1.0 
//
// (c) 2003, www.AspCool.com. All rights reserved.
// ASP酷技术网 版权所有
//
// 该源码下载自:http://www.51aspx.com
// 邮箱:tim@aspcool.com
//
// 版权声明:本程序仅供学习使用,你也可以修改后在网站上使用,但使用时必
// 须保留ASP酷技术网(www.AspCool.com)的版权信息和链接。本程序随《ASP.NET
// 网站建设专家》一书赠送,未经作者同意,不得随意修改、传播。
//
// 描述:
//   此文件包含下面的类:
//       GetPassword
//
// 作者:     王保健
// 时间:     2005-01-15
//
//------------------------------------------------------------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

using System.Configuration;
using System.Web.Mail;

namespace AspCool.WebExpert.Users
{
	/// <summary>
	/// Summary description for GetPassword.
	/// </summary>
	public class GetPassword : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.TextBox txtName;
		protected System.Web.UI.WebControls.Button btnSend;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnSend.Click += new System.EventHandler(this.btnSend_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSend_Click(object sender, System.EventArgs e)
		{
			UsersDB user = new UsersDB();
			SqlDataReader reader = user.GetSingleUser(txtName.Text);

			if (reader.Read())
			{
				MailMessage msg = new MailMessage();
				msg.From = ConfigurationSettings.AppSettings["tim@aspcool.com"];
				msg.To = (System.String)reader["Email"];
				msg.Subject = "ASP酷技术网的密码提示";
				msg.Body = (System.String)reader["Name"] + "你好!<br>你在ASP酷技术网的密码为:" +(System.String)reader["Passport"];
				msg.BodyFormat = MailFormat.Html; 

				SmtpMail.SmtpServer =  ConfigurationSettings.AppSettings["smtpserver"];
				SmtpMail.Send(msg);

				Response.Write("您好!您的密码已经发送到你注册的信箱中去了,请到您的信箱中查看.");
			}
			else
			{
				Response.Write("此用户还没有注册,清<a href=\"register.aspx\">点此注册</a>。");
			}
			Response.End();
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -