问:
我想让一个按钮触发两个事件,submit1_click 和submit2_click()可以吗?怎么设?先执行submit1_click,再接着执行submit2_click。是再OnClick里设还是submit1_click里调用submit2_click呀?(用c#编辑)
______________________________________________________________________________________________
答1:
可以
button1.Click += new System.EventHandler( this.submit1_click );
button1.Click += new System.EventHandler( this.submit2_click );
______________________________________________________________________________________________
答2:
up
______________________________________________________________________________________________
答3:
只要能触发就好处理了,哪怕是N个事件页能通过自己的程序代码来实现!
______________________________________________________________________________________________
答4:
事件是一个特殊的组播代表,而组播代表的特点就是可以注册多个事件处理程序
______________________________________________________________________________________________
答5:
你也可以采用,在事件1中启用事件2的方法来处理
______________________________________________________________________________________________
答6:
这样
submit1.Click += new System.EventHandler( this.submit1_click );
submit1.Click += new System.EventHandler( this.submit2_click );
______________________________________________________________________________________________
答7:
<asp:button id="submit1" OnClick+=new System.EventHandler(this.submit1_click) OnClick+=new System.EventHandler(this.Submit2_click) runat="server"/>
这样写错在那里呀,显示的错误是:服务器标记的格式不正确.
代码还需要在其他地方声明 EventHandler吗?
______________________________________________________________________________________________
答8:
放到系统初始化的那段代码里
______________________________________________________________________________________________
答9:
详细说说好吗?
______________________________________________________________________________________________
答10:
private void InitializeComponent()
{
submit1.Click += new System.EventHandler( this.submit1_click );
submit1.Click += new System.EventHandler( this.submit2_click );
}
______________________________________________________________________________________________
答11:
不行呀,submit1受保护级别限制
______________________________________________________________________________________________
答12:
可以,void 返回值的可以进行多路委托。
______________________________________________________________________________________________
答13:
学习
______________________________________________________________________________________________
答14:
不如在一个按钮的事件中加入对另一个事件的触发
本文来自: 乘风原创程序(http://www.qqcf.com) 详细出处参考:http://study.qqcf.com/web/717/235098.htm