惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Tenable Blog
S
SegmentFault 最新的问题
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园 - 聂微东
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
美团技术团队
Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
P
Proofpoint News Feed
aimingoo的专栏
aimingoo的专栏
博客园_首页
宝玉的分享
宝玉的分享
C
Check Point Blog
爱范儿
爱范儿
MyScale Blog
MyScale Blog
Microsoft Azure Blog
Microsoft Azure Blog
The Register - Security
The Register - Security
U
Unit 42
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
D
Docker
博客园 - Franky
博客园 - 【当耐特】
腾讯CDC
N
Netflix TechBlog - Medium
Jina AI
Jina AI
博客园 - 司徒正美
Last Week in AI
Last Week in AI
PCI Perspectives
PCI Perspectives
GbyAI
GbyAI
Security Archives - TechRepublic
Security Archives - TechRepublic
J
Java Code Geeks
Cloudbric
Cloudbric
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Y
Y Combinator Blog
F
Full Disclosure
TaoSecurity Blog
TaoSecurity Blog
N
News and Events Feed by Topic
L
LINUX DO - 最新话题
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
小众软件
小众软件
O
OpenAI News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Security Affairs
Recent Announcements
Recent Announcements
Attack and Defense Labs
Attack and Defense Labs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Secure Thoughts

博客园 - pot

在框架中(IFRAME/FRAMESET)传递COOKIE的解决方案[转] jQuery图片播放插件Fancybox使用方法 C#生成缩略图代码 数据抓取的一个类,包含一些常用的方法 抓取AJAX网页的方法-Firefox组件,C#集成 C#编号的ActiveX控件采用CAB的布署方式实例 C#编写ActiveX控件实例(包括命令和事件) PdfAcroViewer C#代码登录活动目录 用XML反序列化快速完成ASP.NET配置文件 - pot - 博客园 android Activity类的使用 Android中的Intent详细讲解 Android模拟器常用使用,和基本功能使用 ZPL II 命令参考 正则表达式语法 - pot - 博客园 《C#异常处理》 C#中接口的作用 The RSA key container could not be opened - pot ASP.NET 页面事件执行顺序
关于object sender,EventArgs e 的一些解释
pot · 2008-03-04 · via 博客园 - pot

( object sender , EventArgs e )      是C#里面的事件响应的代码,在我们打印的课本的122页里面有讲到一些,结合网上的一些资料,总结如下:
EventArgs是包含事件数据的类的基类,用于传递事件的细节。
EventHandler是一个委托声明如下(其在.Net类库中如下声明的)
public delegate void EventHandler( object sender , EventArgs e )
所以,所有形如:  void 函娄名(object 参数名,EventArgs 参数名); 的函数都可以作为Control类的Click事件响应方法了。object的参数名一般用Source或Sender来表示,两个没有区别。
如下面所定义的一个事件响应方法:
private void button1_Click(object sender, System.EventArgs e)
参数object sender表示引发事件的对象(其实这里传递的是对象的引用,如果是button1的click事件则sender就是button1),System.EventArgs e 代表事件的相应信息。


下面我们可以看下Button类的事件声明,以Click事件为例。
public event EventHandler Click;
这里定义了一个EventHandler类型的事件Click
private void button1_Click(object sender, System.EventArgs e)
             {
                       ...
                 }
这是我们和button1_click事件所对应的方法。
那我们怎么把这个方法和事件联系起来呢,请看下面的代码。
this.button1.Click += new System.EventHandler(this.button1_Click);   
把this.button1_Click方法绑定到this.button1.Click事件。

以上原理简单理解下就可以了,在实际操作中我们只需要在代码里面调用Web控件里面使用button控件,里面的属性OnClick="button1_Click" 语句便可以起到调用方法的功能了。在VS。NET中可以直接在设计页面加入button, 而上面红色的那行代码编译器会自动实现(可在cs代码文件里面看到)。