惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Stack Overflow Blog
Stack Overflow Blog
L
LINUX DO - 最新话题
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
Spread Privacy
Spread Privacy
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
V
Vulnerabilities – Threatpost
K
Kaspersky official blog
S
Schneier on Security
B
Blog
The Register - Security
The Register - Security
SecWiki News
SecWiki News
Hacker News: Ask HN
Hacker News: Ask HN
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
S
Security Affairs
T
The Blog of Author Tim Ferriss
G
Google Developers Blog
T
Tenable Blog
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
D
DataBreaches.Net
S
Secure Thoughts
Security Latest
Security Latest
H
Heimdal Security Blog
The Hacker News
The Hacker News
O
OpenAI News
AWS News Blog
AWS News Blog
量子位
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
U
Unit 42
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Hugging Face - Blog
Hugging Face - Blog
The Last Watchdog
The Last Watchdog
Recorded Future
Recorded Future
V2EX - 技术
V2EX - 技术
爱范儿
爱范儿
F
Full Disclosure

博客园 - 键盘上的烟灰

网页游戏开发入门教程三(简单程序应用) 网页游戏开发入门教程二(游戏模式+系统) 网页游戏开发入门教程一(webgame+design) (转)ASP.NET MVC V2 第一个预览版发布了 SNS介绍 WPF的路由事件概述 官方Windows 7 RC Build 7100官方下载,序列号申请,汉化 Sql Server 2008官方简体中文正式版 为VS 2008添加AJAX Control Toolkit3.5 JavaScript编辑器下载---1st JavaScript Editor Po3.8(已解决智能提示失效问题) JavaScript中的Cookies JavaScript中的事件 CSS属性大全(适合初级,高手绕道) ASP.NET验证控件详解 给初学编程的一点建议 常用工具下载 通用分页存储过程 WebService服务和ajax使用 用正则判断所输入的Email是否合法
N久前写的一个基于1.1的ASP.NET登录复合控件
键盘上的烟灰 · 2008-08-11 · via 博客园 - 键盘上的烟灰

代码如下:

using System;
using System.ComponentModel; //大多和可视化相关
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


namespace Complex
{
/*
  *Login是本控件的默认事件,[DefaultEvent("Login")]
  如果在设计器上双击此控件,将会自动生成Login的事件响应
  */
[DefaultEvent("Login")]
public class LoginControl :
  System.Web.UI.WebControls.WebControl,
  System.Web.UI.INamingContainer
  //实现System.Web.UI.INamingContainer接口
  //此接口无任何成员,只要控件类实现了
  //此接口,就具备,控件ID + 冒号 + 内部控件ID
  //作为客户端HTML标记name属性,而控件ID + 下划线
  //+ 内部控件ID作为客户端HTML标记id属性的功能
{
  private TextBox txtUserName;
  private TextBox txtPassword;
  private Button btnLogin;
  public LoginControl()
  {
   //确保控件被拖放到ASP.NET设计器的时候,
   //马上创建子控件
   this.EnsureChildControls();
  }
  protected override void CreateChildControls()
  {
   this.Controls.Clear();
   this.txtUserName = new TextBox();
   this.txtUserName.ID = "TxtUserName";
   this.txtUserName.Width = Unit.Parse("100px");
   this.txtPassword = new TextBox();
   this.txtPassword.ID = "TxtPassword";
   this.txtPassword.TextMode = TextBoxMode.Password;
   this.txtPassword.Width = Unit.Parse("100px");
   this.btnLogin = new Button();
   this.btnLogin.ID = "BtnLogin";
   this.btnLogin.Text = "登陆";
   this.Controls.Add(new LiteralControl("<table><tr><td>用户名</td><td>"));
   this.Controls.Add(this.txtUserName);
   this.Controls.Add(new LiteralControl("</td></tr><tr><td>密码</td><td>"));
   this.Controls.Add(this.txtPassword);
   this.Controls.Add(new LiteralControl("</td></tr><tr><td colspan=\"2\" align=\"right\">"));
   this.Controls.Add(this.btnLogin);
   this.Controls.Add(new LiteralControl("</td></tr></table>"));
   this.ChildControlsCreated = true;
  }
  [
  Category("登陆"), //设置属性窗口(按类别察看)中,属性的类别
  Description("获取或设置用户名") //设置属性窗口下方对该属性的文本提示
  ]
  public virtual string UserName
  {
   get
   {
    return this.txtUserName.Text;
   }
   set
   {
    this.txtUserName.Text = value;
   }
  }
  [
  Category("登陆"), //设置属性窗口(按类别察看)中,属性的类别
  Description("获取或设置密码") //设置属性窗口下方对该属性的文本提示
  ]
  public virtual string Passord
  {
   get
   {
    return this.txtPassword.Text;
   }
   set
   {
    this.txtPassword.Text = value;
   }
  }
  protected override bool OnBubbleEvent(object source, EventArgs args)
  {
   if(source == this.btnLogin)
   {
    EventHandler handler =
     (EventHandler)this.Events[keyLogin];
    if(handler != null)
     handler(this, EventArgs.Empty);
    return true;
   }
   return base.OnBubbleEvent (source, args);
  }
  private readonly static object keyLogin = new object();
  [
  Category("登陆"), //设置事件窗口(按类别察看)中,属性的类别
  Description("当用户点击登陆按钮的时候触发") //设置事件窗口下方对该属性的文本提示
  ]
  public event EventHandler Login
  {
   add
   {
    this.Events.AddHandler(keyLogin, value);
   }
   remove
   {
    this.Events.RemoveHandler(keyLogin, value);
   }
  }
}
}