Article ID: 814745 - Last Review: December 3, 2007 - Revision: 3.5 Information about the AutoEventWireup attributeSUMMARYThis article describes the AutoEventWireup attribute:
MORE INFORMATIONIn Visual Studio .NET or in Visual Studio 2005, events are bound to event-handler
methods using event delegates. If you use the Web Forms Designer to design Web Forms, the designer automatically generates code to
bind events to their event-handler methods. In Visual Basic .NET or in Visual Basic 2005, the designer performs this binding using the Handles keyword in the declaration of the event-handler method. The following sample code illustrates the Handles keyword in Visual Basic .NET or in Visual Basic 2005: For example, the Page_Init and Page_Load event-handler methods are explicitly called by the ASP.NET page framework, without using the Handles keyword or an explicit event delegate. However, the drawback of using the AutoEventWireup attribute to automatically associate page events and their event-handler methods, is that event-handler methods must have standard, predefined names. This limits how you can name event-handler methods. Visual Studio .NET and Visual Studio 2005 do not have the same limitation on method names. In Visual Studio .NET and in Visual Studio 2005, the default setting for AutoEventWireup is FALSE. Additionally, the designer always uses the Handles keyword or an explicit event delegate to bind events to their event-handler methods. As a result, you can use non-standard names for event-handler methods. ConclusionWhen you explicitly set AutoEventWireup to TRUE, Visual Studio .NET or Visual Studio 2005, by default, generates code to bind events to their event-handler methods. At the same time, the ASP.NET page framework automatically calls the event-handler methods based on their predefined names. This can lead to the same event-handler method being called two times when the page runs. Therefore, Microsoft recommends that you always set AutoEventWireup to FALSE while working in Visual Studio .NET.REFERENCESFor more information, visit the following MSDN Web
sites: ASP.NET Server Control Event Model http://msdn2.microsoft.com/en-us/library/59t350k3(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/59t350k3(vs.71).aspx) @
Page http://msdn2.microsoft.com/en-us/library/ydy4x04a(vs.71).aspx (http://msdn2.microsoft.com/en-us/library/ydy4x04a(vs.71).aspx) APPLIES TO
| Article Translations
|
Back to the top
