开发者

ASP.NET what is the meaning of AutoEventWireup and Inherits?

开发者 https://www.devze.com 2023-01-16 02:28 出处:网络
Given the following statement, <%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"XXX.aspx.cs\" Inherits=\"XXX\" %>

Given the following statement,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="XXX.aspx.cs" Inherits="XXX" %>
  1. What is the meaning of AutoEventWireup?
  2. What if the value of AutoEventWireup is equal to false
  3. What is the meaning of XXX in the Inherits attribute?
  4. I cannot find the def开发者_Go百科inition of XXX in the auto-created file in ASP.NET 2008. Where is the XXX defined?

Thank you


AutoEventWireup = false means that your Page_Load event will not be automatically hooked to the page's Load event and so on for PreRender and the other page lifecycle events. It means in the constructor of your code-behind base class for the Page, you will have to manually do

Load += new ..EventHandler(Page_Load) etc

Inherits tells the page which class is the base class for the class that the runtime will generate when your application starts up. The auto-generated class will be in the ASP namespace and be put in the Temporary ASP.NET Files and will inherit from your class. This is how protected properties and event declarations in your code-behind can actually serve as handlers that are specified in the declarative .aspx markup

XXX is usually side-by-side right next to the aspx file and is the same name as the aspx file, unless it is Default, in which case that is a C# keyword, so sometimes it uses _default as the class name while the page itself is Default.aspx.

You should probably try to read some tutorials on ASP.NET page inheritance, here is an example, but you should search for more:

http://west-wind.com/weblog/posts/3016.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消