notify.cs
来自「C#邮件代码库,用于邮件发送」· CS 代码 · 共 94 行
CS
94 行
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web.UI.WebControls;
using System.ComponentModel;
//*********************************************************************
//
// Notify Class
//
// WebControl that displays a checkbox indicating whether or not
// user has requested a notification email when new items are listed.
//
//*********************************************************************
public class Notify : CheckBox {
SectionInfo objSectionInfo;
PageInfo objPageInfo;
UserInfo objUserInfo;
//*********************************************************************
//
// Notify Constructor
//
// Retrieves the UserInfo, SectionInfo, and PageInfo objects
// from context. This control hides itself if notification
// is not enabled for this section.
//
//*********************************************************************
public Notify() : base() {
if (Context != null) {
objSectionInfo = (SectionInfo)Context.Items["SectionInfo"];
objPageInfo = (PageInfo)Context.Items["PageInfo"];
objUserInfo = (UserInfo)Context.Items["UserInfo"];
this.CssClass = "NotifyLink";
// hide me if notification or comments not enabled
if (!objSectionInfo.EnableNotifications || (!objSectionInfo.EnableComments && objPageInfo.ID != -1))
Visible = false;
}
// Enable autopostback
AutoPostBack = true;
}
//*********************************************************************
//
// OnLoad Method
//
// Checks the checkbox when the user has asked to be notified.
//
//*********************************************************************
protected override void OnLoad(EventArgs e) {
if (!Page.IsPostBack)
Checked = NotifyUtility.GetNotificationStatus(objPageInfo.ID, objSectionInfo.ID, objUserInfo.Username);
// call base method
base.OnLoad(e);
}
//*********************************************************************
//
// OnCheckedChanged Method
//
// Changes notification status for user in database.
// If the user is not authenticated, redirects to login page.
//
//*********************************************************************
protected override void OnCheckedChanged(EventArgs e) {
// Check if authenticated
if (!objUserInfo.IsAuthenticated)
CommunityGlobals.ForceLogin();
// Update Database
NotifyUtility.UpdateNotificationStatus(objPageInfo.ID, objSectionInfo.ID, objUserInfo.Username, Checked);
// call base method
base.OnCheckedChanged(e);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?