本文介绍了“对象发送者"的用途是什么?和"EventArgs e"参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Page_LoadInit和其他页面事件的情况下,这些(object sender, EventArgs e)参数的用途是什么?

In case of Page_Load, Init and other page events, what is the use of these (object sender, EventArgs e) parameters?

示例会更有用.

推荐答案

EventArgs e是一个名为e的参数,其中包含事件数据,有关更多信息,请参见EventArgs MSDN页面.

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

Object Sender是一个名为Sender的参数,其中包含对引发事件的控件/对象的引用.

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

事件Arg类: http://msdn.microsoft.com/zh-CN/library/system.eventargs.aspx

示例:

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

单击Button后,将触发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 e"参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 23:45