各位高手帮解释一下?急
下面的代码,错在哪?
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace testcontrol
{
/// <summary>
/// WebCustomControl1 的摘要说明。
/// </summary>
public delegate void myclick(object sender,System.EventArgs e);
public class WebCustomControl1 : System.Web.UI.WebControls.WebControl,INamingContainer
{
private string text;
public event myclick onclick;
[Bindable(true),
Category("Appearance"),
DefaultValue("")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
/// <summary>
/// 将此控件呈现给指定的输出参数。
/// </summary>
/// <param name="output"> 要写出到的 HTML 编写器 </param>
protected override void Render(HtmlTextWriter output)
{
addcontrol();
base.Render(output);
}
private void addcontrol()
{
Button b=new Button();
b.Text="click me";
b.ID="test1";
b.Click+=new myclick(this.bclick);
this.Controls.Add(b);
}
public void bclick(object sender,System.EventArgs e)
{
if(this.onclick!=null)
{
this.onclick(this,e);
}
}
}
}