473,748 Members | 7,608 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 1425
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
3166
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
1847
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
1778
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
3637
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
1524
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
3612
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
1438
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
1620
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
2412
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
8989
marktang
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...
0
8828
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
9367
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...
0
8241
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...
0
4599
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4869
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3309
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2213
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.