最近需要用到panel,并在后台代码中动态生成button控件。
同时也要为此控件添加OnClick事件。
然而在属性中只有OnClientClick事件。
因此需要通过如下代码添加OnClick事件:
- yourButton.Click += new System.EventHandler(this.yourFunction);
- yourFunction(object sender, EventArgs e)
- {
- ....
- }
需要注意函数的参数需写为(object sender, EventArgs e)的形式。
转载于:https://blog.51cto.com/wurongzong/571095