472,122 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

Auto Event wireup

366 256MB
Hello

can any body please give exact for AutoEventwireup=true;

AutoEventwireup=false;

by default it is false in which we hav to make it as true what is the exact use of

this

Please dont send any msdn web link and other web site links


thanks and regards

nmsreddi
Jan 17 '07 #1
3 4508
radcaesar
759 Expert 512MB
When we create a new ASP.NET Web Application in Visual Studio .NET, by default, the value of the AutoEventWireup attribute is set to false in the .aspx page and event handlers are automatically created. We can find this in the InitializeComponent method:

this.Load += new System.EventHandler(this.Page_Load);

The best way to see the working of this attribute would be:

* Declare a string variable msg as public in WebForm1.aspx.cs.
* In the HTML section of WebForm1.aspx, enter the following code in the <Head> section:

<% Response.Write(msg); %>

In the Page_Load, you could enter a value for the variable msg declared.

msg= "We are in Page_Load()";

On running the application, you will get the message We are in Page_Load() [hereafter referred to as message]. Note: this is in the default case where the attribute is set to false.

Now try commenting the event handler code for the Page_Load in the aspx.cs file; and set the AutoEventWireup attribute to false in the .aspx page. On running the application this time, you will not get the message.

Now with the event handler code for the Page_Load in the aspx.cs file still commented; set the AutoEventWireup attribute to true in the .aspx page. On running the application this time, you will get the message.

Reason: In the case where AutoEventWireup attribute is set to false (by default), event handlers are automatically required for Page_Load or Page_Init. However, when we set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.

Source: Code Project

:)


Hello

can any body please give exact for AutoEventwireup=true;

AutoEventwireup=false;

by default it is false in which we hav to make it as true what is the exact use of

this

Please dont send any msdn web link and other web site links


thanks and regards

nmsreddi
Jan 17 '07 #2
nmsreddi
366 256MB
thanks mr RAD

you have given some good stuff

can you say some situations when it is needed to be true ,any drawbacks with

that default value autoeventwireup=false;
Jan 18 '07 #3
When we create a new ASP.NET Web Application in Visual Studio .NET, by default, the value of the AutoEventWireup attribute is set to false in the .aspx page and event handlers are automatically created. We can find this in the InitializeComponent method:

this.Load += new System.EventHandler(this.Page_Load);

The best way to see the working of this attribute would be:

* Declare a string variable msg as public in WebForm1.aspx.cs.
* In the HTML section of WebForm1.aspx, enter the following code in the <Head> section:

<% Response.Write(msg); %>

In the Page_Load, you could enter a value for the variable msg declared.

msg= "We are in Page_Load()";

On running the application, you will get the message We are in Page_Load() [hereafter referred to as message]. Note: this is in the default case where the attribute is set to false.

Now try commenting the event handler code for the Page_Load in the aspx.cs file; and set the AutoEventWireup attribute to false in the .aspx page. On running the application this time, you will not get the message.

Now with the event handler code for the Page_Load in the aspx.cs file still commented; set the AutoEventWireup attribute to true in the .aspx page. On running the application this time, you will get the message.

Reason: In the case where AutoEventWireup attribute is set to false (by default), event handlers are automatically required for Page_Load or Page_Init. However, when we set the value of the AutoEventWireup attribute to true, the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.

Source: Code Project

:)

Great Thanks To You.
I know detail because of you.
is that only for Page Events ?

regards,
<X>
Jan 18 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Brian | last post: by
7 posts views Thread by Oisin Grehan | last post: by
1 post views Thread by Roger | last post: by
3 posts views Thread by localhost | last post: by
3 posts views Thread by csgraham74 | last post: by
6 posts views Thread by Mark Chambers | last post: by
5 posts views Thread by Andrew Robinson | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.