Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: ASP.NET Website Programming Problem-Design-Solution
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 23rd, 2004, 09:52 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding Page_Load to base class doesn't work

The code in the book says the base class should have...

protected override void OnInit(EventArgs e)
{
    this.OnInit(e);
    this.Load += new System.EventHandler(this.TestPage_Load);
}

and that this will get called BEFORE the inherited class page load event. However, auto-generated code in VS2003 shows the following...

override protected void OnInit(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);
}

This means that the load even for the generated page will ALWAYS get called before our base class load event.

What gives? And what is the best way around this? I assume any chances to auto-gen code will get stamped over, plus it would be a major pain in the a$$ to fix this for every page.

Regards

Rael


  #2 (permalink)  
Old September 23rd, 2004, 10:03 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Typo in first post, function should read...

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    this.Load += new System.EventHandler(this.TestPage_Load);
}

I was playing and forgot to set it back.

  #3 (permalink)  
Old September 24th, 2004, 06:30 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Atlanta, Georgia, USA.
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

>I assume any chances to auto-gen code will get stamped over, plus it would
>be a major pain in the a$$ to fix this for every page

I change the auto-gen code in this case. It hasn't ever lost my changes. Some people say this change gets undone by VS, but I have never seen that myself.

It's not terribly hard to switch the order of 2 statements on every page. You're going to do a lot more work than that to each new page you write.

This all changes in ASP.NET 2.0. They have an improved model for handling identity and user personalization. The new master page concept also simplies this type of code by eliminating the user controls for things like the header and footer of each page. As I mentioned before, ThePhile in ASP.NET 2.0 could have a lot fewer lines of code, and still have more functionality.

However, this same code will still compile and run correctly under 2.0. It would require a fundamental redesign to get most of the big advantages of 2.0.

Eric
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Base Class for Code-Behind Problem groupmatch BOOK: ASP.NET Website Programming Problem-Design-Solution 3 September 8th, 2004 05:06 AM
classes :: base class is inaccessible .... Kaliste C# 3 July 16th, 2004 04:56 AM
base class inheritance krunch97 VB.NET 2002/2003 Basics 6 April 23rd, 2004 11:48 AM
Page_Load override with base page class nebrown1 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 31st, 2003 04:45 AM
Help with DBObject base class projectedNexus BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 12th, 2003 06:36 PM



All times are GMT -4. The time now is 01:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.