Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What Are The Difference Between AutoEventWireup="true" and
AutoEventWireup="False"

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain server control extensibility with reference to asp.net 2.0 ?

1004


What is the difference between localization and globalization?

1043


Which is better union or union all?

1074


Explain the features that make asp.net more used framework? : asp.net mvc

946


How can you implement encapsulation in asp.net?

13073


What is the used of "ispostback" property?

1129


Explain the difference between dataset and datareader.

1021


Tell me the code snippet to show how we can return 404 errors from HttpError?

1285


Write some code using interfaces, virtual methods, and an abstract class`

2060


What is the life-span of the items in the viewstate?

957


How do you create a master page?

1050


What are web beacons used for?

1025


What are the different types of validation controls in asp.net?

1057


Explain the difference between webfarm and webgardens in .net?

988


Can the unique key be null?

1114