Web Form Designer generated code

G

Guest

Dear colleagues,
Does anyone have an idea where I could find precise and detailed
explanation of each and every statement of the following “Web Form Designer
generated codeâ€:


#region Web Form Designer generated code
override protected void OnInit(aS.EventArgs e) {
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>

private void InitializeComponent() {
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion


I’ve my good reasons to ask for this grass-root “precise and detailed
explanationâ€, that I’ll be glad to expose, were anybody interested to.

Thanks for your attention.
P.M.
 
D

DalePres

The first section is an override of the Page.OnInit method. It is overriden
to implement the call to InitializeComponent, where the event handlers and
other initialization steps are created. The base.OnInit(e) call is required
because you generally want to call the base method of any overridden method.

The last main component is the line that starts with this.Load +=. This
line registers an event handler for the Page.Load event. By default, the
IDE calls the event handler method Page_Load.

This is pretty basic functionality of VS2003 and ASP.Net. If you need more
you could just go to MSDN as another resonder suggests but you'd be better
off starting with something introductory such as Microsoft Press'
Step-By-Step series titles on ASP.Net and C#.

HTH

DalePres
MCAD, MCDBA, MDSE
 
G

Guest

I’m delighted by your courtesy, and competence. Heartily thanks.

Reason for this question is that I cannot anymore accept passively such
automatically generated code because of the fact that, in some circumstances
(that I can reproduce at will), my code is victim of a Page_Load multiple
“firingâ€. In other words the Page_Load event handler inexplicably enters more
than once and, at the second entry, Login credentials are asked again
interactively.
Were anybody interested in this “incident†I’ll be more than pleased to let
know and discuss it.

Thanks again for your support.
Pietro
- - - - -=- - - - -=- - - - -=- - - - -=- - - - -=- - - - -=- - - - -=
 
D

DalePres

In the Page directive at the top of your ASPX file, look for the
AutoEventWireup attribute and make sure it is set to false. Alternatively,
you can eliminate that code and use the AutoEventWireup capabilities.

A lot of developers don't use either of those models and manually create all
their code but then some developers still develop in Notepad, as well. My
preference is the first choice, set AutoEventWireup to false, let the tools
do the grunt work, and you do the fun stuff.

Here's an article that might help:

http://msdn.microsoft.com/library/d.../en-us/vbcon/html/vbconwebformseventmodel.asp

HTH

DalePres
MCAD, MCDBA, MCSE
 
G

Guest

Dear Mr. HTH – DalePres,
Could we keep discussing this topic? Indeed, in my opinion, it is yet
far from clear and under (my) control.
Please consider the following points.

1) Here we are not exactly in presence of a “Server Control†event, are we?
And the reference “ASP.NET Server Control Event Model†doesn’t exactly apply,
does it?

2) By definition “events associated with server controls are raised on the
client but handled on the Web server by the ASP.NET page frameworkâ€. But here
we are BEFORE the posting of an .aspx page to a client computer. Or, better,
this is (I presume) exactly that very event.

3) I haven’t found any documentation about Page.OnInit, only about
Control.OnInit; and I’m not sure it is the same thing. Is it?

4) Problem is that sometimes (that I can reproduce) the event Page_Load is
triggered (“firesâ€) more than once, and this is disruptive for my current
project.

As you see I’m really confused (and baffled too…). Could we keep discussing
this topic?
Thanks for your time.
P.M.
 
G

Guest

Hello,

I had the same problem -- rename your Login.aspx page to something else and
it will work fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top