为什么一个事件的访问修饰符在默认情况下保护?情况下、事件、修饰符

由网友(愿你余生不孤寂)分享简介:保护无效ButtonSheel_Click(对象发件人,EventArgs五)protected void ButtonSheel_Click(object sender, EventArgs e)推荐答案标记起来用于(在运行时)定义一个类继承自你的code定义背后的类(你可以看到在 @Page 的声明,我们定...

保护无效ButtonSheel_Click(对象发件人,EventArgs五)

protected void ButtonSheel_Click(object sender, EventArgs e)

推荐答案

标记起来用于(在运行时)定义一个类继承自你的code定义背后的类(你可以看到在 @Page 的声明,我们定义页面所继承什么类)

The mark up is used (at runtime) to define a class which inherits from the class defined in your code behind (you can see this in the @Page declaration where we define what class the page inherits from)

<%@ Page Inherits="_Default" ...

这个类必须能够访问你定义要为你的控件的事件处理程序(单击按钮等),所以他们需要被标记为至少保护(而不是私人),以允许这些方法的方法继承的标记类的访问。

This class needs access to the methods that you define to be the event handlers for your controls (button clicks etc...), and so these methods they need to be marked as at least protected (rather than private) to allow the inheriting markup class access.

阅读全文

相关推荐

最新文章