473,890 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Base Page Design Question

I am in the process of setting up a base page model for multiple reasons.
One of the reasons is so that I can catch all exceptions when derived pages
throw/raise them. I don't want to use the standard OnError virtual method to
handle this requirement because the form does not complete its rendering
process when this occurs. I really need the form to display properly on the
screen.

I have managed to catch nearly all exceptions by overriding the following
virtual methods in the base page: OnInit, OnLoad, OnUnload and
RaisePostBackEv ent. The RaisePostBackEv ent virtual method is ideal for
capturing post back events triggered by Web controls, such as button clicks.
What is missing from this model is the ability to capture the changed event
that Web controls may raise/throw. This path is routed via a separate page
method called RaiseChangedEve nts. This method is unfortunately both non
virtual and private.

Currently my work around is to subclass all Web controls and wrap exception
handling inside their own OnXXX virtual methods. Can anyone suggest a better
solution or work around here please?

Thanks in advance,

Tony.


Nov 19 '05 #1
4 1433
Tony,

Protected Overrides Sub OnInit(ByVal e As EventArgs)

MyBase.OnInit(e )

AddHandler Me.Error, AddressOf PageBase_Error

End Sub

Protected Sub PageBase_Error( ByVal Sender As Object, ByVal e As EventArgs)

Dim curError As Exception = Server.GetLastE rror

' Write error to log file or something ...

' Show Error on screen

' Clear error so that it does not buble up to Application Level
Server.ClearErr or()

End Sub

HTH,
Jurjen.

"Tony" <oc************ @optusnet.com.a u> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I am in the process of setting up a base page model for multiple reasons.
One of the reasons is so that I can catch all exceptions when derived pages
throw/raise them. I don't want to use the standard OnError virtual method
to handle this requirement because the form does not complete its rendering
process when this occurs. I really need the form to display properly on the
screen.

I have managed to catch nearly all exceptions by overriding the following
virtual methods in the base page: OnInit, OnLoad, OnUnload and
RaisePostBackEv ent. The RaisePostBackEv ent virtual method is ideal for
capturing post back events triggered by Web controls, such as button
clicks. What is missing from this model is the ability to capture the
changed event that Web controls may raise/throw. This path is routed via a
separate page method called RaiseChangedEve nts. This method is
unfortunately both non virtual and private.

Currently my work around is to subclass all Web controls and wrap
exception handling inside their own OnXXX virtual methods. Can anyone
suggest a better solution or work around here please?

Thanks in advance,

Tony.

Nov 19 '05 #2
Thanks for your tip Jurjen but as I stated in my original message, handling
exceptions inside OnError prevents ASP.NET from rendering the Web form. This
is a major requirement for me, unless someone knows of a way to get the .NET
framework to render a Web form once OnError has caught an exception? If so,
then I can avoid subclassing every .NET Web control.

Regards,
Tony.
"Jurjen de Groot" <in**@gits-online.nl> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Tony,

Protected Overrides Sub OnInit(ByVal e As EventArgs)

MyBase.OnInit(e )

AddHandler Me.Error, AddressOf PageBase_Error

End Sub

Protected Sub PageBase_Error( ByVal Sender As Object, ByVal e As EventArgs)

Dim curError As Exception = Server.GetLastE rror

' Write error to log file or something ...

' Show Error on screen

' Clear error so that it does not buble up to Application Level
Server.ClearErr or()

End Sub

HTH,
Jurjen.

"Tony" <oc************ @optusnet.com.a u> wrote in message
news:%2******** *******@tk2msft ngp13.phx.gbl.. .
I am in the process of setting up a base page model for multiple reasons.
One of the reasons is so that I can catch all exceptions when derived
pages throw/raise them. I don't want to use the standard OnError virtual
method to handle this requirement because the form does not complete its
rendering process when this occurs. I really need the form to display
properly on the screen.

I have managed to catch nearly all exceptions by overriding the following
virtual methods in the base page: OnInit, OnLoad, OnUnload and
RaisePostBackEv ent. The RaisePostBackEv ent virtual method is ideal for
capturing post back events triggered by Web controls, such as button
clicks. What is missing from this model is the ability to capture the
changed event that Web controls may raise/throw. This path is routed via
a separate page method called RaiseChangedEve nts. This method is
unfortunately both non virtual and private.

Currently my work around is to subclass all Web controls and wrap
exception handling inside their own OnXXX virtual methods. Can anyone
suggest a better solution or work around here please?

Thanks in advance,

Tony.


Nov 19 '05 #3
Tony wrote:
I am in the process of setting up a base page model for multiple
reasons. One of the reasons is so that I can catch all exceptions
when derived pages throw/raise them. I don't want to use the standard
OnError virtual method to handle this requirement because the form
does not complete its rendering process when this occurs. I really
need the form to display properly on the screen.


Isn't this a bogus requirement? If there's an exception while rendering
a page, how can you ever be sure to render the rest of the page in a
meaningful way?

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e
Nov 19 '05 #4
Yes and no.

Yes because if a system throws an exception then it makes sense to redirect
a user to a different page altogether because like you said, who knows what
state the page could be in.

No because we are using a sub classed rendition of ApplicationExce ption to
act as a user error exception, thus allowing us trap all user errors at a
default (common) location and render the error on the same page with all
controls in tact because like I said, in the end it's a user error not a
system exception. For our requirement, when a user error is raised in a
large and complex system it would be appropriate to automatically unwind the
call stack to the top-most level and render the user error message on the
same Web page with all controls in tact. Regardless, we have to place
try/finally statements throughout our code to ensure that we close all
opened resources when an exception is thrown, such as database connections.
Now you might say that overloading exception handling this way was not its
intention and I will agree with you, but this solution allows us to code
error handling securely and with minimal effort. This error handling model
avoids us from unwinding the call stack programmaticall y by checking the
return value of every function call (and there many of them), thus making
the code bloated, less readable and prone to failure by missing a few checks
along the way.

Hope this helps in the understanding of our system design requirement.

Regards,
Tony.
"Joerg Jooss" <ne********@joe rgjooss.de> wrote in message
news:xn******** ********@msnews .microsoft.com. ..
Tony wrote:
I am in the process of setting up a base page model for multiple
reasons. One of the reasons is so that I can catch all exceptions
when derived pages throw/raise them. I don't want to use the standard
OnError virtual method to handle this requirement because the form
does not complete its rendering process when this occurs. I really
need the form to display properly on the screen.


Isn't this a bogus requirement? If there's an exception while rendering
a page, how can you ever be sure to render the rest of the page in a
meaningful way?

Cheers,
--
http://www.joergjooss.de
mailto:ne****** **@joergjooss.d e

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3173
by: vijay | last post by:
Hello I wanted to understand a contradictory design of C++ class A {public: virtual void f(){ cout<<" base f"<<endl; } }; class B:public A {
1
1856
by: Matthias Kaeppler | last post by:
Sorry if this has been discussed before (I'm almost certain it has), but I didn't know what to google for. My problem is, I have a class, a gtkmm widget, and I want it to serve as a base class now, but I'm not sure if I'm taking the proper steps in order to not break the whole class. Are there any guidelines what I have to watch out for? One question would e.g. be:
2
1784
by: Mike Taylor | last post by:
I'm trying to create a base page class for my project (am new to ASP.NET, so am a bit stumped) - I'm using VS.NET 2003, btw. OK, my dummy base page class is shown below: using System; using System.Web; using System.Web.UI; using System.Web.Security; using System.Security.Principal;
1
3641
by: Axel Dahmen | last post by:
Hi, I've added a property to my Page base class (this base class inherits from Page and all my aspx.cs classes inherit from my base class). This property of mine uses the Session object to determine its return information. After implementing this property, whenever I now open any aspx page in the Visual Studio 7.0 IDE, the following error shows up: "The file failed to load in the Web form designer. Please correct the
4
1534
by: rgrandidier | last post by:
I have already created a base class that incorporates common functionlity into my ASP.Net application, what I want to do is have it have a design time interface where I can show it in VS IDE. Specifically I have HTML that defines my page layout and I want to show it during design time. How do I provide a design time interface to my base class that derives from System.Web.UI.Page? -- Robert
5
3619
by: eiji | last post by:
Hi folks, I hope this is not "off topic"! :-) Consider the next code: /* Declarations of types that could become platform-dependent */ #define MyChar char #define MyInt int
0
1444
by: Swami | last post by:
I have 2 questions relating to website design in asp .net: 1. In a website that I am building I have everything as a user control. Even the header, which contains the navigation tabs is in a user control which is placed on every page. Originally, the reason why I chose to do it this way (instead of placing the header in a master page) is because my header tabs change dynamically based on who the user is. My question is, am I losing...
3
1630
by: Filimon Roukoutakis | last post by:
Dear all, assuming that through a mechanism, for example reflexion, the Derived** is known explicitly. Would it be legal (and "moral") to do this conversion by a cast (probably reinterpret would work here)? The conversion is done for this purpose: I have an std::map<std::string, Base*>. I want to "associate" Derived* handles to the stored Base* so when Base* in the map changes (ie points another address), the Derived* handle outside of...
2
2419
by: cmonthenet | last post by:
Hello, I searched for an answer to my question and found similar posts, but none that quite addressed the issue I am trying to resolve. Essentially, it seems like I need something like a virtual static function (which I know is illegal), but, is there a way to provide something similar? The class that is the target of my inquiry is a template class that interfaces to one of several derived classes through a pointer to a base class. The...
0
9822
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11232
Oralloy
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...
0
10819
jinu1996
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...
1
10923
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9633
agi2029
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...
1
8016
isladogs
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...
0
7169
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6045
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3277
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.