小弟我用C#写了一个自定义登录控件,增加了事件响应机制 但点击登录或重置控件时事件却无响应,到底错哪了?以下是自定义控件代码
我用C#写了一个自定义登录控件,增加了事件响应机制 但点击登录或重置控件时事件却无响应,到底哪里错了?以下是自定义控件代码
using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Web.Security;
namespace kongjian
{
/// <summary>
/// LoginCustomControl 的摘要说明。
/// </summary>
[DefaultProperty( "Text "),
DefaultEvent( "ItemChanged "), //双击响应
ParseChildren(true),
Description( "Login Control "),
Designer(typeof(kongjian.LoginControlDesigner)),//指定了登录控件的设计器类
ToolboxData( " <{0}:LoginCustomControl runat=server> </{0}:LoginCustomControl> ")]
public class LoginCustomControl : System.Web.UI.WebControls.WebControl
{
public static string USERNAME_STRING = "用户名: ";
public static string PASSWORD_STRING = "密 码: ";//两个字中间留空格
public static string LOGIN_STRING = "登录 ";
public static string RESET_STRING = "重置 ";
public static string CAPTION_STRING = "用户登录 ";
public static string REGISTER_STRING = "注册新用户 ";
private TextBox tbUserName;
private TextBox tbPassword;
private Button btnLogin;
private Button btnReset;
private LiteralControl vUserName;
private LiteralControl vPassword;
private LinkButton lbRegister;
private bool _show_register;
public event EventHandler Login;
public event EventHandler Reset;
public event EventHandler Register;
protected void OnLogin(EventArgs e)
{
if (Login != null)
{
Login(this, e);
}
}
protected void OnReset(EventArgs e)
{
if (Reset != null)
{
Reset(this, e);
}
}
protected void OnRegister(EventArgs e)
{
if (Register != null)
{
Register(this, e);
}
}
public string UserName
{
get
{
this.EnsureChildControls();
return tbUserName.Text;
}
set
{
this.EnsureChildControls();
tbUserName.Text = value;
}
}
public string Password
{
get
{
this.EnsureChildControls();
return tbPassword.Text;
}
set
{
this.EnsureChildControls();
tbPassword.Text = value.ToString();
}
}
[
Browsable(true),
Category( "Behaviour "),
Description( "是否显示注册新用户链接 ")
]
public bool ShowRegister
{
get
{
return _show_register;
}
set
{
_show_register = value;
}
}
protected override void CreateChildControls()
{
base.CreateChildControls ();
//文本
using System;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Web.Security;
namespace kongjian
{
/// <summary>
/// LoginCustomControl 的摘要说明。
/// </summary>
[DefaultProperty( "Text "),
DefaultEvent( "ItemChanged "), //双击响应
ParseChildren(true),
Description( "Login Control "),
Designer(typeof(kongjian.LoginControlDesigner)),//指定了登录控件的设计器类
ToolboxData( " <{0}:LoginCustomControl runat=server> </{0}:LoginCustomControl> ")]
public class LoginCustomControl : System.Web.UI.WebControls.WebControl
{
public static string USERNAME_STRING = "用户名: ";
public static string PASSWORD_STRING = "密 码: ";//两个字中间留空格
public static string LOGIN_STRING = "登录 ";
public static string RESET_STRING = "重置 ";
public static string CAPTION_STRING = "用户登录 ";
public static string REGISTER_STRING = "注册新用户 ";
private TextBox tbUserName;
private TextBox tbPassword;
private Button btnLogin;
private Button btnReset;
private LiteralControl vUserName;
private LiteralControl vPassword;
private LinkButton lbRegister;
private bool _show_register;
public event EventHandler Login;
public event EventHandler Reset;
public event EventHandler Register;
protected void OnLogin(EventArgs e)
{
if (Login != null)
{
Login(this, e);
}
}
protected void OnReset(EventArgs e)
{
if (Reset != null)
{
Reset(this, e);
}
}
protected void OnRegister(EventArgs e)
{
if (Register != null)
{
Register(this, e);
}
}
public string UserName
{
get
{
this.EnsureChildControls();
return tbUserName.Text;
}
set
{
this.EnsureChildControls();
tbUserName.Text = value;
}
}
public string Password
{
get
{
this.EnsureChildControls();
return tbPassword.Text;
}
set
{
this.EnsureChildControls();
tbPassword.Text = value.ToString();
}
}
[
Browsable(true),
Category( "Behaviour "),
Description( "是否显示注册新用户链接 ")
]
public bool ShowRegister
{
get
{
return _show_register;
}
set
{
_show_register = value;
}
}
protected override void CreateChildControls()
{
base.CreateChildControls ();
//文本