📄 message.cs
字号:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//*********************************************************************
//
// Message Class
//
// Represents the Message Page. The Message page displays a text
// message to the user. For example: "The content in this section
// is moderated".
//
//*********************************************************************
public class Message : SkinnedCommunityControl {
string _skinFileName = "Messages_Message.ascx";
Label lblMessage;
Button btnContinue;
string messageName;
//*********************************************************************
//
// Message Constructor
//
// Calls the base SkinnedCommunityControl constructor
// and assigns the default page skin.
//
//*********************************************************************
public Message() : 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"; }
}
//*********************************************************************
//
// ReturnUrl Property
//
// Specifies the URL that the user is redirected back to
// after reading the message.
//
//*********************************************************************
string ReturnUrl {
get {
if (ViewState["ReturnUrl"] == null)
return "Default.aspx";
return (string)ViewState["ReturnUrl"];
}
set { ViewState["ReturnUrl"] = value; }
}
//*********************************************************************
//
// InitializeSkin Method
//
// Retrieves all the controls from the Page Skin
//
//*********************************************************************
override protected void InitializeSkin(Control skin) {
// Get the message name
messageName = Context.Request.QueryString["message"];
// Get the Return URL
ReturnUrl = Context.Request.QueryString["ReturnUrl"];
// Find the Message Label
lblMessage = (Label)GetControl(skin, "lblMessage");
// Find Continue Button
btnContinue = (Button)GetControl(skin, "btnContinue");
btnContinue.Click += new System.EventHandler(btnContinue_Click);
}
//*********************************************************************
//
// OnLoad Method
//
// Assigns values to the controls from the page skin.
//
//*********************************************************************
override protected void OnLoad(EventArgs e) {
EnsureChildControls();
MessageInfo _messageInfo = MessageUtility.GetMessage(messageName);
lblMessage.Text = _messageInfo.Body;
}
//*********************************************************************
//
// btnContinue_Click Method
//
// Returns the user back to the ReturnUrl page.
//
//*********************************************************************
void btnContinue_Click(Object s, EventArgs e) {
Context.Response.Redirect(CommunityGlobals.CalculatePath(ReturnUrl));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -