页面中有个Label和TextBox,ID分别lblContLen和txtContent,当txtContent的内容被修改时,欲在lblContLen动态提示,但是接收委托事件失败,请高手指教?谢谢!
添加控件: protected Label lblContLen = new Label();
protected TextBox txtContent = new TextBox(); protected override void CreateChildControls() { ...
lblContLen.ID = "lblContLen";
txtContent.ID = "txtContent";
//txtContent.OnTextChanged += new EventHandler(testfunc);//这样写没通过,原因是OnTextChanged受保护的 frmForm.Controls.Add(lblContLen);
frmForm.Controls.Add(txtContent);
...
} void Page_Load(object sender, System.EventArgs e)
{
txtContent.OnTextChanged += new EventHandler(testfunc);//想必须在Page_Load中写,但这样写也没通过
}
void testfunc(EventArgs e)//此处是否只用EventArgs,而无须用object
{
lblContLen.Text="内容已被修改!";
}