?? passwordreminder.cs
字號:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNET.StarterKit.Communities;
using System.Web.Security;
//*********************************************************************
//
// PasswordReminder Class
//
// Represents the Password Reminder page which enables users to
// receive an email password reminder.
//
//*********************************************************************
public class PasswordReminder : SkinnedCommunityControl {
string _skinFileName = "Users_PasswordReminder.ascx";
TextBox txtEmail;
Button btnSend;
Button btnCancel;
Panel pnlForm;
Panel pnlInvalidEmail;
Panel pnlSent;
//*********************************************************************
//
// PasswordReminder Constructor
//
// Calls the base SkinnedCommunityControl constructor
// and assigns the default page skin.
//
//*********************************************************************
public PasswordReminder() : base() {
// Assign a default skin file name
if (SkinFileName == null)
SkinFileName = _skinFileName;
}
//*********************************************************************
//
// SkinType Property
//
// Specifies the skins directory where this page's skin file is located.
//
//*********************************************************************
override protected string SkinType {
get { return "ContentSkins"; }
}
//*********************************************************************
//
// InitializeSkin Method
//
// Retrieves all the controls from the Page Skin
//
//*********************************************************************
override protected void InitializeSkin(Control skin) {
// Find the Email TextBox
txtEmail = (TextBox)GetControl(skin, "txtEmail");
// Find the Form Panel
pnlForm = (Panel)GetControl(skin, "pnlForm");
// Find the Invalid Email Panel
pnlInvalidEmail = (Panel)GetControl(skin, "pnlInvalidEmail");
pnlInvalidEmail.Visible = false;
// Find the Sent Panel
pnlSent = (Panel)GetControl(skin, "pnlSent");
pnlSent.Visible = false;
// Find Send Button
btnSend = (Button)GetControl(skin, "btnSend");
btnSend.Click += new System.EventHandler(btnSend_Click);
// Find Cancel Button
btnCancel = (Button)GetControl(skin, "btnCancel");
btnCancel.CausesValidation = false;
btnCancel.Click += new System.EventHandler(btnCancel_Click);
}
//*********************************************************************
//
// btnSend_Click Method
//
// Sends the password reminder and displays the Sent panel.
//
//*********************************************************************
void btnSend_Click(Object s, EventArgs e) {
if (Page.IsValid) {
// Get User Profile
ProfileInfo _profileInfo = UserUtility.GetProfileFromEmail(txtEmail.Text);
if (_profileInfo == null) {
pnlInvalidEmail.Visible = true;
return;
}
else
pnlInvalidEmail.Visible = false;
// Get the reminder message
MessageInfo reminderEmail = MessageUtility.GetMessage("Password Reminder");
// Send formatted email
EmailUtility.SendFormattedEmail
(
String.Format("reminder@{0}", CommunityGlobals.PrimaryDomain),
reminderEmail,
_profileInfo,
CommunityGlobals.SmtpServer
);
}
pnlForm.Visible = false;
pnlSent.Visible = true;
}
//*********************************************************************
//
// btnCancel_Click Method
//
// Cancels the password reminder and redirects the user back
// to the Default page.
//
//*********************************************************************
void btnCancel_Click(Object s, EventArgs e) {
Context.Response.Redirect("~/Default.aspx");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -