What Are The Difference Between AutoEventWireup="true" and
AutoEventWireup="False"
Answers were Sorted based on User's Feedback
Answer / vishnu prasad.c
When you set the value of the AutoEventWireup attribute to
false, you must manually hook up events to event handlers.
When you set the value of the AutoEventWireup attribute to
true, the ASP.NET page framework can automatically raise
events.
Is This Answer Correct ? | 39 Yes | 5 No |
Answer / uma
Dont read all the those things simply understand
actually AutoEventWireup is written in page directive like
this
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
by default it is "true", that means all the events that are
automatically rises when page is loading
if AutoeventWireUp=false then we have to manually write
events and delegates like this
public _Default() // ctor
{
Load += new EventHandler(Page_Load);
PreInit += new EventHandler(Page_PreInit);
}
protected void Page_Load(object sender, EventArgs e)
{
// ...
}
protected void Page_PreInit(object sender, EventArgs e)
{
// ...
}
Is This Answer Correct ? | 20 Yes | 1 No |
Answer / navneet
When you set the value of the AutoEventWireup attribute to
false, you must manually hook up events to event handlers.
such as Page_Load() etc.
When you set the value of the AutoEventWireup attribute to
true, the ASP.NET page framework can automatically raise
events.
such as Page_Load() etc.
Is This Answer Correct ? | 21 Yes | 3 No |
Answer / vinodh reddy
The default value for AutoEventWireup is true for a C# web
form, and false for a VB.NET web form. The IDE adds the
default values to the @ Page directive for a new web form.
The difference in defaults is partly because VB.NET has a
mechanism for defining an event handler and subscribing to
an event in one graceful motion (the Handles keyword).
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load
' ...
End Sub
An easy way to generate the above code is to use the drop
down controls that sit just above the editor. Note: C#
doesn t make the dropdown list of events available when
editing a code-beside file, but the dropdown is available
when writing in-line code.
There is no equivalent to the Handles keyword in C#
(anonymous event handlers are arguably close, but just not
the same). When AutoEventWireup is true, all we need to do
is follow the method naming convention of
Page_EventToHandle. The ASP.NET runtime will automatically
find and fire the method for the appropriate event.
protected void Page_Load(object sender, EventArgs e)
{
}
Once Again, In Reverse
If we switch to AutoEventWireup= true for a VB.NET web
form, we can use the magic Page_EventName approach. The
only change to the earlier VB.NET code would be to drop the
Handles clause, and the events fire correctly.
If we switch to AutoEventWireup= false for a C# web form,
there is a little extra work to do. Somewhere we need to
explicitly wire up events. Here is one approach.
public partial class _Default : Page
{
public _Default() // ctor
{
Load += new EventHandler(Page_Load);
PreInit += new EventHandler(Page_PreInit);
}
protected void Page_Load(object sender, EventArgs e)
{
// ...
}
protected void Page_PreInit(object sender, EventArgs e)
{
// ...
}
}
Is This Answer Correct ? | 17 Yes | 3 No |
Answer / kapil sharma
Dont be too confuse in this question for understand
actually AutoEventWireup is written in page directive like
this
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default2.aspx.cs" Inherits="Default2" %>
by default it is "true", that means all the events that are
automatically rises when page is loading
if AutoeventWireUp=false then we have to manually write
events and delegates like this
public _Default() // ctor
{
Load += new EventHandler(Page_Load);
PreInit += new EventHandler(Page_PreInit);
}
protected void Page_Load(object sender, EventArgs e)
{
// ...
}
protected void Page_PreInit(object sender, EventArgs e)
{
// ...
}
So by default its means all event automatically wire up
when page load and if its false we have do some extra
work....
Is This Answer Correct ? | 4 Yes | 0 No |
Answer / anil jadhav
here is the proper valid answer
AutoEventWireup attribute
AutoEventWireup is a Boolean attribute that indicates
whether events of a Web Forms page are autowired.The default
value for AutoEventWireup is TRUE.
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.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles MyBase.Load
The ASP.NET page framework supports an alternative mechanism
that uses the AutoEventWireup attribute of a Web Forms page
to automatically associate page events and event-handler
methods. If the AutoEventWireup attribute of the @ Page
directive is set to TRUE (or if it is not specified because
its default value is TRUE), the ASP.NET page framework
automatically calls page event-handler methods.
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.
Conclusion
When 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.
Is This Answer Correct ? | 5 Yes | 2 No |
Answer / firoz khan
if the AutoEventWireup="true" than the event of page load automatic genreate
else
genreated by hendler or created him self if u can
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / karthees
AutoEventWireup= true:-)
When value of the AutoEventWireup attribute is set to true, the ASP.NET page framework can automatically raise events.
AutoEventWireup= false:-)
When value of the AutoEventWireup attribute is set to false, one must manually call the events to event handlers.
Is This Answer Correct ? | 1 Yes | 1 No |
Answer / meganadha reddy k.
I guess what you mean is AutoPostBack="true" in which the
index change of a drop down box will be posted back to
server.
Please correct me if I am wrong.
To know the difference between autoEventWireup="true" and
autoEventWireup="false" please refer the below link:
http://support.microsoft.com/kb/324151
Regards,
Meganadha Reddy K.
Is This Answer Correct ? | 6 Yes | 8 No |
Answer / ruchika garg
First of all the above answer that default value for auto
eventwireup=true is false bcoz the default value of
autoeventwireup=false in c#
A false value indicates that you must explicitly write a
code to bind events related to a page ,such as the load
event of a page
and true value indicates that events will be generated
automatically
Is This Answer Correct ? | 1 Yes | 9 No |
What’s the catch?
What is the function used for removing an event listener?
What is the namespace used to store the information about the user?s locale?
What are asynchronous callbacks?
What for use web.sitemap in asp.net?
What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
How can we make sure that Web API returns JSON data only?
What is runtime host ?
Describe a Windows Service and its lifecycle ?
What is asp.net and how it works?
Suppose you want an asp.net function (client side) executed on the mouseover event of a button. Where do you add an event handler?
hi i have a problem regarding to datagrid in aspdotnet.i have a datagrid in my application.i have to place add,edit,delete buttons or links what ever it may be. now the problem is if i click on add button then the page has to redirected to another form called "xyz.aspx" and if i click on edit button the page has to redirected to another form called "abc.aspx".i am phasing the problem that if where ever i click on the datagrid the cursor goes to gv1_SelectedIndexChanged event.please tell me the solution about the code.