Hi All,
I have a requirement. I am throwing an exception from the Page_Load of my
user control I want
to catch this in my container page. Is this possible?
The Page_Load of user control is executed after the Page_Load of the page.
So we cannot catch this in the Page_Load of the page. So my question where
in the page i will catch the exception thrown form the user control.
I don't want any event to be raised from the user control.
PLEASE HELP ME.
Thanks
Prince 4 1623
You can have an error handler at the Page level (Page_Error) which catches
the error and does some processing, but it might have other effects
(unwanted ones) on your app. But try it out.
Personally if it is known that error is raised I would either:
-Try to handle it in the UC itself (own error handler there) and not let
Page do anything with it
or
-if Page needs know about it but doesn't need to do more, indeed raise an
event from the UC
And please note that raising exceptions shouldn't be normal logic, but they
would really need to be used in exceptional situations. Maybe you could
redesign it so that Page invokes the action in UC by calling UC's method,
when it could also handle possible exceptions or return data coming from the
method call (which would indicate error case)
But all these depends on what you need to do withing the Page 8there could
be other alternatives as well). Write the error data for user or something?
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message
news:OT******** ******@TK2MSFTN GP12.phx.gbl... Hi All,
I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is executed after the Page_Load of the page. So we cannot catch this in the Page_Load of the page. So my question where in the page i will catch the exception thrown form the user control.
I don't want any event to be raised from the user control.
PLEASE HELP ME.
Thanks
Prince
Hi,
"Write the error data for user or something?" Thats what i want. But with
out handling the error event or raising an event from the UC can i catch
that exception from the container Page.
Thanks
Prince
"Teemu Keiski" <jo****@aspalli ance.com> wrote in message
news:eg******** ******@TK2MSFTN GP09.phx.gbl... You can have an error handler at the Page level (Page_Error) which catches the error and does some processing, but it might have other effects (unwanted ones) on your app. But try it out.
Personally if it is known that error is raised I would either:
-Try to handle it in the UC itself (own error handler there) and not let Page do anything with it
or
-if Page needs know about it but doesn't need to do more, indeed raise an event from the UC
And please note that raising exceptions shouldn't be normal logic, but they would really need to be used in exceptional situations. Maybe you could redesign it so that Page invokes the action in UC by calling UC's method, when it could also handle possible exceptions or return data coming from the method call (which would indicate error case)
But all these depends on what you need to do withing the Page 8there could be other alternatives as well). Write the error data for user or something?
-- Teemu Keiski ASP.NET MVP, AspInsider Finland, EU
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message news:OT******** ******@TK2MSFTN GP12.phx.gbl... Hi All,
I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is executed after the Page_Load of the page. So we cannot catch this in the Page_Load of the page. So my question where in the page i will catch the exception thrown form the user control.
I don't want any event to be raised from the user control.
PLEASE HELP ME.
Thanks
Prince
> But with out handling the error event or raising an event from the UC can i catch that exception from the container Page.
Nope, because there isn't anything in "middle" that would initiate that
logic from page, or where you could plug your own code (as long as you keep
it withing Load event of the UC). As I said, it would mean a change so that
Page is the responsible for initiating the action (calling the method in UC
which can cause the error) if you want to have try...catch block to handle
it
Exception in Page_Error comes as general Exception type. If you'd want it
typed, you'd need to check the type first and cast to it (if there's chance
for expections of multiple type). Page_Error runs for all unhandled
exceptions.
Maybe you could get around it by assigning the Label or what the error msg
should be written to, as a proprrty from page to the UC, so UC could set it
itself. Or its ID. Anyways, its your call. The responibility goes into two
possible ways here, either Page does the writing or then UC does it. If Page
does it, it needs to get to the exception somehow and these are the means.
-
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
..
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message
news:Oj******** ******@tk2msftn gp13.phx.gbl... Hi,
"Write the error data for user or something?" Thats what i want. But with out handling the error event or raising an event from the UC can i catch that exception from the container Page.
Thanks Prince
"Teemu Keiski" <jo****@aspalli ance.com> wrote in message news:eg******** ******@TK2MSFTN GP09.phx.gbl... You can have an error handler at the Page level (Page_Error) which catches the error and does some processing, but it might have other effects (unwanted ones) on your app. But try it out.
Personally if it is known that error is raised I would either:
-Try to handle it in the UC itself (own error handler there) and not let Page do anything with it
or
-if Page needs know about it but doesn't need to do more, indeed raise an event from the UC
And please note that raising exceptions shouldn't be normal logic, but they would really need to be used in exceptional situations. Maybe you could redesign it so that Page invokes the action in UC by calling UC's method, when it could also handle possible exceptions or return data coming from the method call (which would indicate error case)
But all these depends on what you need to do withing the Page 8there could be other alternatives as well). Write the error data for user or something?
-- Teemu Keiski ASP.NET MVP, AspInsider Finland, EU
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message news:OT******** ******@TK2MSFTN GP12.phx.gbl... Hi All,
I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is executed after the Page_Load of the page. So we cannot catch this in the Page_Load of the page. So my question where in the page i will catch the exception thrown form the user control.
I don't want any event to be raised from the user control.
PLEASE HELP ME.
Thanks
Prince
Thanks
Teemu
"Teemu Keiski" <jo****@aspalli ance.com> wrote in message
news:eT******** ******@TK2MSFTN GP14.phx.gbl... But with out handling the error event or raising an event from the UC can i catch that exception from the container Page.
Nope, because there isn't anything in "middle" that would initiate that logic from page, or where you could plug your own code (as long as you keep it withing Load event of the UC). As I said, it would mean a change so that Page is the responsible for initiating the action (calling the method in UC which can cause the error) if you want to have try...catch block to handle it
Exception in Page_Error comes as general Exception type. If you'd want it typed, you'd need to check the type first and cast to it (if there's chance for expections of multiple type). Page_Error runs for all unhandled exceptions.
Maybe you could get around it by assigning the Label or what the error msg should be written to, as a proprrty from page to the UC, so UC could set it itself. Or its ID. Anyways, its your call. The responibility goes into two possible ways here, either Page does the writing or then UC does it. If Page does it, it needs to get to the exception somehow and these are the means.
- Teemu Keiski ASP.NET MVP, AspInsider Finland, EU
.
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message news:Oj******** ******@tk2msftn gp13.phx.gbl... Hi,
"Write the error data for user or something?" Thats what i want. But with out handling the error event or raising an event from the UC can i catch that exception from the container Page.
Thanks Prince
"Teemu Keiski" <jo****@aspalli ance.com> wrote in message news:eg******** ******@TK2MSFTN GP09.phx.gbl... You can have an error handler at the Page level (Page_Error) which catches the error and does some processing, but it might have other effects (unwanted ones) on your app. But try it out.
Personally if it is known that error is raised I would either:
-Try to handle it in the UC itself (own error handler there) and not let Page do anything with it
or
-if Page needs know about it but doesn't need to do more, indeed raise an event from the UC
And please note that raising exceptions shouldn't be normal logic, but they would really need to be used in exceptional situations. Maybe you could redesign it so that Page invokes the action in UC by calling UC's method, when it could also handle possible exceptions or return data coming from the method call (which would indicate error case)
But all these depends on what you need to do withing the Page 8there could be other alternatives as well). Write the error data for user or something?
-- Teemu Keiski ASP.NET MVP, AspInsider Finland, EU
"Prince Mathew" <pr************ ****@hotmail.co m> wrote in message news:OT******** ******@TK2MSFTN GP12.phx.gbl... Hi All,
I have a requirement. I am throwing an exception from the Page_Load of my user control I want to catch this in my container page. Is this possible? The Page_Load of user control is executed after the Page_Load of the page. So we cannot catch this in the Page_Load of the page. So my question where in the page i will catch the exception thrown form the user control.
I don't want any event to be raised from the user control.
PLEASE HELP ME.
Thanks
Prince
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jim O'Neil [Sybase] |
last post by:
In designing a new control for general use, I have come across a design
decision involving exceptions...
I know that TargetSite returns the name of the method that threw the
exception; however, will users of the control expect that TargetSite always
reflects the method of the control that they actually called? For example,
consider a method on my class named "publicfoo" that calls some internal
method name "internalbar" (which includes...
|
by: Professor Frink |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on...
|
by: craig |
last post by:
I am wondering if there are some best practices for determining a strategy
for using try/catch blocks within an application.
My current thoughts are:
1. The code the initiates any high-level user tasks should always be
included in a try/catch block that actually handles any exceptions that
occur (log the exception, display a message box, etc.).
2. Low-level operations that are used to carry out the high level tasks
|
by: |
last post by:
I am looking for a easy way to trap an Exception that may occurr in any one
of 30 child web controls to be trapped at the topmost parent WebUser control
or Page Level. I have tried variations of setting the Error event handler
for the topmost parent WebUser control that I want to handle the error to no
avail.
Sample code from the MSDN seems to imply that this can be done but it can
only be taken care of at the same user control level as...
|
by: Diego F. |
last post by:
I think I'll never come across that error. It happens when running code from
a DLL that tries to write to disk. I added permissions in the project
folder, the wwwroot and in IIS to NETWORK_SERVICE and Everyone, with Full
Control to see if it's a permissions problem.
The project is hosted in a Windows 2003 Server and developed from PCs in a
domain, developing with Visual Studio 2005 Beta 1.
--
Regards,
| |
by: Craig831 |
last post by:
First off, I apologize if this gets long. I'm simply trying to give you all
enough information to help me out. I'm writing (almost finished, actually),
my first VB.Net application. It's a forms application that is going to be
used to extract data from a legacy system (VSAM based mainframe file
structure), and output data in pipe-delimited record layouts, multiple record
types per file, one file per chosen client. I have been working on...
|
by: Gursharan |
last post by:
Hi,
I get this error after I did a load test on my website (500 constant user
load in team system for 35 minutes). This error is logged after about 1
minute of load testing and is logged every 60 seconds. Any ideas?
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 30/07/2006 21:56:12
Event time (UTC): 30/07/2006 20:56:12
|
by: Ben Crinion |
last post by:
Hi
Im having a bit of a problem with an exception that doesnt seem to be
bubbling up from a user control to its containing user control.
The exception can occur on an event fired by a user control which is within
another user control which is on a content page.
I cant catch the exception in the containing user control because its not
occuring as a result of a method call so i thought i would try and use the
|
by: Efi Merdler |
last post by:
Hi,
I created a user control, but instead of handling exception in the
user control level I prefer to handle them in the containing form.
In the load event of the containing form I'm using:
entryWindow.Error += new EventHandler(Page_Error);
when entryWindow is my user control.
Two questions:
|
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: 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,...
| |
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: 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,...
|
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: 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...
| |