?? custommodule.cs
字號:
namespace ASPNET.StarterKit.Communities {
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web;
using ASPNET.StarterKit.Communities;
//*********************************************************************
//
// CustomModule Class
//
// Displays a user control (.ascx file) in the content area of
// a community page.
//
//*********************************************************************
[ParseChildren(true)]
public class CustomModule : WebControl, INamingContainer {
//*********************************************************************
//
// CreateChildControls Method
//
// Loads user control into Controls collection. The user control
// must be located at the following path:
//
// ~/Communities/[communityName]/CustomModules/[sectionName].ascx
//
//*********************************************************************
protected override void CreateChildControls() {
string skinFileName;
Control skin;
// Determine skin file name
CommunityInfo objCommunityInfo = (CommunityInfo)HttpContext.Current.Items[ "CommunityInfo" ];
SectionInfo objSectionInfo = (SectionInfo)HttpContext.Current.Items[ "SectionInfo" ];
skinFileName = String.Format( "{0}/Communities/{1}/CustomModules/{2}.ascx", CommunityGlobals.AppPath, objCommunityInfo.Name, objSectionInfo.Name );
try {
skin = Page.LoadControl(skinFileName);
Controls.Add(skin);
}
// Catch errors so they can be displayed.
catch (HttpException he) {
Controls.Add(new LiteralControl(he.GetHtmlErrorMessage()));
Context.Trace.Warn( "community error","HttpException ::",he);
}
catch (System.IO.FileNotFoundException fnf) {
string errorMessage = fnf.Message+" Not Found";
Controls.Add( new LiteralControl(errorMessage) );
Context.Trace.Warn("community error",errorMessage,fnf);
}
// guess that the file was not found?
catch (Exception e) {
string errorMessage = "An unknown exception caused static page ("+skinFileName+") load abort -- see trace file for more info";
Controls.Add( new LiteralControl( errorMessage ) );
Context.Trace.Warn( "community error", errorMessage, e);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -