hi frnds by default AutoEventwireup value is false.If value is true we do not have to write the below event InitializeComponent. But by default, value is false & even we do not write the foll. event InitializeComponent ,then how the page load is called????
If it's set to "True", the ASP.NET runtime does not require events to specify event handlers like Page_Load etc.,
Once you create a new webform in VS.NET the 'AutoEventWireup' attribute of that page would be false. Open the code behind file and check out the 'InitializeComponent' it would be something like this:
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
When AutoEventWireup is True, you do not need to associate the event handlers. It automatically associates the event handlers for you. The procedure name should be in a specific format for this to work i.e. Object_Event. e.g. Page_Init, Page_Load
When AutoEventWireup is False, then you need to explicitly associate event handlers with the corresponding methods, in one or the other way. This does not need you to name the procedure in any specific format. Also, this is better performancewise as compared to AutoEventWireup=True.
The default value of AutoEventWireup is True. So when you don't specify, this is True.
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
Last edited by Pradeep1210; Nov 30th, 2009 at 02:56 PM.
Pradeep, Microsoft MVP (Visual Basic) Please appreciate posts that have helped you by clicking icon on the left of the post.
"A problem well stated is a problem half solved." — Charles F. Kettering
hello pradeep sir.These two sites are not opened in my computer,cz msdn sites are not opened up in my computer.
Suppose I set the AutoEventWireUp=False.Then the page load event is not called by itself.I want to ask that how to generate event private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
} .
To generate page load event we just double click on form.& event is generated.How to generate InitializeComponent event.
I m not able to see that,I add the form & generate load event,i see the foll. code-
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Sorry for my mistake. I thought it is an Windows Application.
Yes in Web Application it is not calling the Page_Load event if you set the event wireup to false. For this create one Public Constructor with the Page name and associate the Page Load event there as
Code:
public _Default()
{
this.Load += new EventHandler(Page_Load);
}
protected void Page_Load(object sender, EventArgs e)
{
}
Please mark you thread resolved using the Thread Tools as shown
Why are you not allowed access to MSDN? For a programmer, this is a critical resource!!
Gary
I too agree with Gary. Here the people don't have any sense. I strongly believe that if you are Microsoft developer, you should be allowed to access MSDN . I believe the fellow is from India
Please mark you thread resolved using the Thread Tools as shown
What reason do you need the InitializeComponent for? There's no component to initialize on a web page. If you're looking for an early method, use Init or PreInit.
If you're looking for an easy way to generate them, go to your page view, go to properties window, then click on the lightning bolt. Pick the event you want there, double click in its empty space and it should generate the event for you.
Here is the method of getting the Page events
1.Select the page
2.Right Click, Choose Component Designer, Will display designer.
3.In the Designer , Right Click --> Properties
4. Highlight the thunder icon. Now you will get the Page Events
See the Attached Image
Please mark you thread resolved using the Thread Tools as shown
hi danasegarane thx very much.Tell me one thing more- first method,i write manually.Second method,is generated by your method. They are same or not.??
Because if i write AutoEventWireup to False,then the first method is executed not second one.
FIRST
protected override void OnInit(EventArgs e)
{
this.Load += new EventHandler(Page_Load);
}
SECOND
private void FrmXML_Init(object sender, EventArgs e)
{
this.Load += new EventHandler(Page_Load);
}
I dont know Gep sir,y cant i access MSN from home.Everytime i open msdn page,server not found.I try it in all browsers firefox,chrome,But still cant access msdn??? hey Gep sir i want to ask one thing more,VS 2008 is avaialbe thru net free of cost or not?
I m not able to see that,I add the form & generate load event,i see the foll. code-
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Where is the Initailize Component event??????
Originally Posted by gep13
Hey,
You can get the Visual Studio 2008 Express Editions for free, yes:
hey read the foll. info,Read the bolded part.Its wrong na.by default AutoEventWireup is true ,but below written false,in 2005 we write OnInit event if we set AutoEventWireup to False,but below writen in InitializeComponent() we write??? Below is the case for VS 2003,if i m not wrong???? Last Question!!!!!!
AutoEventWireup is an attribute in Page directive. It's a Boolean attribute which indicates whether the asp.net pages events are auto-wired.
AutoEventWireup will have a value true or false. By default its value is set to false. We can specify the default value of the AutoEventWireup attribute in the following locations:
- The Machine.config file.
- The Web.config file.
- Individual Web Forms (.aspx files).
- Web User Controls (.ascx files)
In Machine.Config or WebConfig file this attribute can be declared as
As we know, when we change Machine.Config file, it will affect all asp.net webforms on the computer and if we change Web.config it will affect that application only. If you want this attribute change in a single webform change in page directive
Understanding its working
AutoEventWireup is false when we create a new web application and event handlers are automatically created. We can find this in the Initialize Component method
this.Load += new System.EventHandler(this.Page_Load);