定制服务器控件:在ASPX代码上声明性地指定事件 [英] Custom server control: specifying event declaratively on ASPX code

查看:106
本文介绍了定制服务器控件:在ASPX代码上声明性地指定事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用多个自定义ASPX服务器控件。当然,这些控件也确实会公开事件。现在,一种可能性是在代码中注册处理程序,更具体地说是在自定义服务器控件所在的页面中注册……例如

I'm currently working on several custom ASPX server controls. Of course these controls do also expose events. Now one possibility is to register a handler in the code, more specifically in the page where the custom server control resides...like

protected void Page_Load(object sender, EventArgs e)
{
   myCustomControl.Click += new ....
}

但是我该如何在服务器控制代码st中公开事件我可以直接在ASPX代码上(从属性编辑器中)声明这些事件处理程序,就像您可以在Button的click事件上进行声明一样?

But how do I have to expose the event in my server control code s.t. I can declare these event handlers directly on the ASPX code (from the Property Editor), similar as you can do it on the Button's click event??

非常感谢,

朱里

推荐答案

您就是这样做的...

You do just that...

如果您在ASCX控件上有一个名为PropertyChanged的公共事件

If you have a public event on your ASCX Control called PropertyChanged

,则该声明将在您的控件上可用为OnPropertyChanged

then it'll be available declaritively on your Control as OnPropertyChanged

<ctl:MyControl ID="abc" runat="server" OnPropertyChanged="abc_PropertyChanged" />

这篇关于定制服务器控件:在ASPX代码上声明性地指定事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆