.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
动态装载

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

1: 基类 SkinnedForumWebControl : WebControl, InamingContainer

1)     默认构造函数

   public SkinnedForumWebControl() {

   // Attempt to get the current user

      user = Users.GetLoggedOnUser();

   // Is the user not availabe - must be anonymous

      if (user == null)

         Users.TrackAnonymousUsers();

   // Set the siteStyle for the page

      if (user != null)

         skinName = user.Skin;

      else

         skinName = Globals.Skin;

   // If we have an instance of context, let's attempt to

   // get the ForumID so we can save the user from writing

   // the code

      if (null != Context) {

         GetPostIDFromRequest();

         GetForumIDFromRequest();

         GetForumGroupIDFromRequest();

         GetReturnURLFromRequest();

       }           

   }

2)     4个自定义的方法

   // Retrieves the PostID,ForumID,ForumGroupID, ReturnUrl from the request querystring/post.

       private void GetPostIDFromRequest()

      private void GetForumIDFromRequest()

       private void ForumGroupID ()

       private void GetReturnURLFromRequest ()

3)      重写方法

     protected override void CreateChildControls() {

        Control skin;

     // Load the skin(.ascx) as an object instance

        skin = LoadSkin();

     // to be overrided , Initialize the control template and populate the control with values          

InitializeSkin(skin);

        Controls.Add(skin);

     }

  4) 属性访问器

2: 继承的类

1)      属性

   // Assign a default template name

      string skinFilename = "Skin-Login.ascx";

   // controls in (.ascx) template

        TextBox username;

        TextBox password;

        Button loginButton;

        CheckBox autoLogin;

2)     构造函数

   public Login() : base() {

   // Assign a default template name

      if (SkinFilename == null)

      SkinFilename = skinFilename;

   }

3)     重写2个基类方法

     protected override void CreateChildControls() {

     // If the user is already authenticated we have no work to do

        if (Page.Request.IsAuthenticated)

        return;

        base.CreateChildControls();

     }

     override protected void InitializeSkin(Control skin) {

     // Find the login button

        loginButton = (Button) skin.FindControl("loginButton");

        loginButton.Click += new System.EventHandler(LoginButton_Click);

     // add more ……

     }

4)     自定义控件方法

     public void LoginButton_Click(Object sender, EventArgs e)


相关文章

相关软件