有什么用(对象发件人,EventArgs的)参数给出 [英] What use (object sender, EventArgs e) parameters give

查看:176
本文介绍了有什么用(对象发件人,EventArgs的)参数给出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的Page_Load 初始化的情况下和其他页面事件

什么是使用这些(对象发件人,EventArgs五)参数?

例子会更有帮助。

推荐答案

EventArgs的是一个参数名为e的包含事件数据,请参阅EventArgs的MSDN页面了解更多信息。

EventArgs e is a parameter called e that contains the event data, see the EventArgs MSDN page for more information.

对象发件人是一个名为Sender参数包含对控制/对象引发事件的参考。

Object Sender is a parameter called Sender that contains a reference to the control/object that raised the event.

事件精氨酸类:<一href=\"http://msdn.microsoft.com/en-us/library/system.eventargs.aspx\">http://msdn.microsoft.com/en-us/library/system.eventargs.aspx

例如:

protected void btn_Click (object sender, EventArgs e){
   Button btn = sender as Button;
   btn.Text = "clicked!";
}

编辑:
当点击按钮后,btn_Click事件处理程序将被解雇。在对象发件人部分将是它被点击的按钮参照

When Button is clicked, the btn_Click event handler will be fired. The "object sender" portion will be a reference to the button which was clicked

这篇关于有什么用(对象发件人,EventArgs的)参数给出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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