I'm trying to better understand the use of inheritance vs. the
implementation of a handler. I wanted to ask this question to the newsgroup.
Each aspx page is a class which Inherits System.Web.UI.P age.
Then, each page has it's own implementation of Private Sub Page_Load and
Private Sub Page_Init to handle the Handles MyBase.Load and Handles
MyBase.Init events (respectively). The programmer (you or me) is supposed to
flesh out the Pgae_Load and, if you are using the Visual Studio designer,
not touch the Page_Init event handlers.
Instead of this, why don't these page classes, which are subclasses of
System.Web.UI.P age just overload the superclasses of the OnInit and OnLoad
classes? That would seem to make more sense from a class hierarchy
standpoint. Each page class, for example
'Instead of this:
Public Class WebForm1
Inherits System.Web.UI.P age
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class
'Do this:
Public Class WebForm1
Inherits System.Web.UI.P age
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'Put user code to initialize the page here
MyBase.OnLoad(e )
End Sub 'OnInit
End Class 4 3102
Disagree,
As the author of the class you should just sequence the code correctly on
the overridden OnLoad method!
It is actually going against MSs own guidelines to attach an event handler
for the same class that is raising the event.
Ben
"Natty Gur" <na***@dao2com. com> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl... Hi,
You can override Onload function but OnLoad() is call by the framework every time the page is loaded. But before the Page_Load() method is called in your code-behind page. This allows you to do some action before Page_load runs and the programmer code in the page_load executes, such as security checking.
Natty Gur, CTO Dao2Com Ltd. 28th Baruch Hirsch st. Bnei-Brak Israel , 51114
Phone Numbers: Office: +972-(0)3-5786668 Fax: +972-(0)3-5703475 Mobile: +972-(0)58-888377
Know the overall picture
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
Disagree,
As the author of the class you should just sequence the code correctly on
the overridden OnLoad method!
It is actually going against MSs own guidelines to attach an event handler
for the same class that is raising the event.
Ben
"Natty Gur" <na***@dao2com. com> wrote in message
news:uK******** ******@TK2MSFTN GP10.phx.gbl... Hi,
You can override Onload function but OnLoad() is call by the framework every time the page is loaded. But before the Page_Load() method is called in your code-behind page. This allows you to do some action before Page_load runs and the programmer code in the page_load executes, such as security checking.
Natty Gur, CTO Dao2Com Ltd. 28th Baruch Hirsch st. Bnei-Brak Israel , 51114
Phone Numbers: Office: +972-(0)3-5786668 Fax: +972-(0)3-5703475 Mobile: +972-(0)58-888377
Know the overall picture
*** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
but, he is the user...
Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114
Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377
Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
but, he is the user...
Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114
Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377
Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
Sorry, I mixed up the code- reposting with correct example now :)
I'm trying to better understand the use of inheritance vs. the
implementation of a handler. I wanted to ask this question to the newsgroup.
Each aspx page is a class which Inherits System.Web.UI.Page. Then, each page
has it's own implementation of Private Sub Page_Load and Private Sub
Page_Init to handle the Handles MyBase.Load and Handles MyBase.Init events...
|
by: canasdaq |
last post by:
Can anyone please help me. I was looking at the article "http://www.eggheadcafe.com/articles/20030603.asp". I am new to .net and know nothing in c#. I want to write a menu in asp.net. Can anyone please help me in converting this c# code to vb.net. I tried, but it is not giving the output. Here is the c# code
using System
using System.Collections
using System.ComponentModel
using System.Data
using System.Drawing
using System.Web
using...
|
by: Stephen Adam |
last post by:
Hi there,
I've just started a c# project at work where I cannot use Visual Studio. I
am trying to pass variables from one form to another. When I try to create
an instance of the sending class in the receiving class I get a "The type or
namespace name 'XXXX' could not be found (are you missing a using directive
or an assembly reference?)" Error.
It seems that even though the sending class resides in the same folder as
the receiving...
|
by: Kevin Phifer |
last post by:
Ok, before anyone freaks out, I have a solution I need to
create that gathers content from maybe different places.
Each one can return a <form> in the html, so its the
classic can't have more than one runat=server form on a
asp.net page. However, I still want developers to be able
to use asp.net controls to create some apps that are
created on the page. So I need multiple forms on a
asp.net page(doesn't everyone). I purchased the...
|
by: Marcel Gelijk |
last post by:
Hi,
I am trying to create a User Control that is located in a seperate class
library. The User Control contains a textbox and a button.
The page generates an exception when it tries to access the code variable
that are supposed to be linked to the contained controls.
It runs fines when everything is contained in a single web form project.
What do I need to do to make it work from a class library?
| |
by: Dave |
last post by:
Hi, this is a follow-up to an earlier question but I really haven't found a
definitive answer in my search
If I have a Base and Derived webform, I've found that the dervived Page_Load
event fires first, then the base Page_Load.
Is the only technique to change this sequence is to override the
Base.Page_Load and explicitely call the base event when you want to as below:
Derived WebForm
|
by: Wylbur via DotNetMonster.com |
last post by:
Hello to all of you geniuses,
I'm having a problem trying to get an Init handler to fire for a Placeholder
control
at the initialization phase. I’ve posted this problem to 3 other ASP.NET
forums,
and noone wants to touch it.
I tried to attach a literal control to a placeholder:
<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>-<>
|
by: harry potter |
last post by:
Hi,
Are there any reasons to use OnInit or Page_Init method to invoke some
code when the Init event is triggered, if at all. Or are they both just
the same?
-S.
|
by: Eugene Anthony |
last post by:
The problem with my coding is that despite removing the records stored
in the array list, the rptPages repeater
control is still visible. The rptPages repeater control displayes the
navigation link (1,2,3 so on). The code can be found in
SubscriptionCart.aspx.cs.
Default.aspx
------------
|
by: =?Utf-8?B?cm9kY2hhcg==?= |
last post by:
hey all,
Is OnInit and Page_Init the same thing?
thanks,
rodchar
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |