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

📄 custommodule.cs

📁 一个ASP.NET下的中文内容管理和社区系统
💻 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 + -