-
[RESOLVED] AutoEventWire up + Confusion
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);
}
-
Re: AutoEventWire up + Confusion
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.
-
Re: AutoEventWire up + Confusion
-
Re: AutoEventWire up + Confusion
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.
-
Re: AutoEventWire up + Confusion
Normally if you create one project and adds one form the InitializeComponent will get added to the page.
-
Re: AutoEventWire up + Confusion
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??????
-
Re: AutoEventWire up + Confusion
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)
{
}
-
Re: AutoEventWire up + Confusion
Quote:
Originally Posted by
sonia.sardana
hello pradeep sir.These two sites are not opened in my computer,cz msdn sites are not opened up in my computer.
I have to ask...
Why are you not allowed access to MSDN? For a programmer, this is a critical resource!!
Gary
-
Re: AutoEventWire up + Confusion
Or You could override the OnInit method of the page
Code:
//public _Default()
//{
// this.Load += new EventHandler(Page_Load);
//}
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void OnInit(EventArgs e)
{
this.Load += new EventHandler(Page_Load);
}
MSDN
-
Re: AutoEventWire up + Confusion
Quote:
Originally Posted by
gep13
I have to ask...
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 :wave:
-
Re: AutoEventWire up + Confusion
I would be interested to know the reason that they are not allowed access though. The whole concept seems very strange to me.
All due respect to this forum, but I would have thought access to public forums would have been restricted before a reputed website like MSDN.
Just my opinion.
Gary
-
Re: AutoEventWire up + Confusion
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.
-
1 Attachment(s)
Re: AutoEventWire up + Confusion
hey guys,I cant access msdn at my home not in office.
Thx danasegarane sir, problem regarding the AutoEventWireup is solved.
hi mendhak sir,I right click the properties of page view(white portion of .aspx page),But i m not any lightning bolt,see in pic.
-
1 Attachment(s)
Re: AutoEventWire up + Confusion
Hello Sonia,
This is what mendhak was referring to:
Attachment 74686
Select the object that you want to create the event handler for, then select the thunderbolt.
I have to ask again...
Why can't you access MSDN from your home?
Gary
-
1 Attachment(s)
Re: AutoEventWire up + Confusion
I agree with Sonia.
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
-
Re: AutoEventWire up + Confusion
Ah, my bad, I missed the fact that we were talking about page events. (Don't know how I missed that :))
Gary
-
Re: AutoEventWire up + Confusion
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);
}
-
Re: AutoEventWire up + Confusion
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?
-
Re: AutoEventWire up + Confusion
Hey,
You can get the Visual Studio 2008 Express Editions for free, yes:
http://www.microsoft.com/exPress/
Gary
-
Re: AutoEventWire up + Confusion
Note this points
I am over riding the OnInit method. But you are not doing
-
Re: AutoEventWire up + Confusion
Wats the difference b/w express & full version???Can u tell me??In express,it supports AJAX controls??
-
Re: AutoEventWire up + Confusion
k k sorry V Sir ,OnInit cannot be generated automatically thru your method,We have to write it manually rite????
-
Re: AutoEventWire up + Confusion
Quote:
Originally Posted by
sonia.sardana
Wats the difference b/w express & full version???Can u tell me??In express,it supports AJAX controls??
I think this will help you:
http://www.microsoft.com/downloads/d...DisplayLang=en
The short answer though is, yes.
-
Re: AutoEventWire up + Confusion
Quote:
Originally Posted by
sonia.sardana
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??????
Quote:
Originally Posted by
gep13
If you are more interested in Web Application I will suggest for Visual Web Developer
-
Re: AutoEventWire up + Confusion
Hey Dana,
I was assuming that this was the case for the OP, but you are correct to point it out.
Gary
-
Re: AutoEventWire up + Confusion
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
<configuration>
<system.web> <pages autoEventWireup="true|false" /> </system.web> </configuration>
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);
-
Re: [RESOLVED] AutoEventWire up + Confusion
hey frnds your contribution make this site just Rocking!!!!!!!!!!!!!!!
-
Re: [RESOLVED] AutoEventWire up + Confusion
That article is talking about web applications. You may be dealing with web sites which is a different type of project.