473,394 Members | 1,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

UserControl Error event not raised

I added an Error event to a web usercontrol (ascx), but when an error is
raised in the control it does not get called...only the Application_Error
even in the global.asax gets called. The same thing in an aspx works
correctly. Does the Error event not really work with a user control or is
there something I am misunderstanding?
Using Framework 1.1 - VS2003

Thanks
Code Example:
==============================
Public Class WebUserControl1
Inherits System.Web.UI.UserControl

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'bad code which causes an error
Dim x As DataTable
Dim y As DataRow = x.Rows(0)

End Sub

Private Sub Page_Error(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Error
'do something here
'add a debug breakpoint to test error raised.
End Sub
End Class


Nov 19 '05 #1
1 1844
Hi Brad,

Welcome to ASP.NET newsgroup.
As for the Error event handler of the ASP.NET's UserControl, this seems to
be a existing problem. In fact, the MSDN document hasn't described it
correctly. The UserControl's error handler will not be called when there
occurs unhandled exception during the page's execution. Because the Error
Handler mechanism (like the Page.Error event) is implemented by use a large
try...catch ....

block in the System.Web.UI.Page.ProcessRequestMain function(internal
function), when exception occurs, it will explicitly call the page's error
event handler if exists. However, any other sub control(UserControl)'s
handler won't be detected. The following blog article as also mentioned
this problem:

#The not so clear Error event
http://weblogs.asp.net/vga/archive/2003/06/16/8748.aspx

So currently the only means to intercept the global error is to hook the
Page's Error event or the Application_Error event. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Nov 19 '05 #2

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

Similar topics

1
by: jralford | last post by:
Hi, Another question from a C# newbie: I have a usercontrol class that includes a customized control. Now, if I create an instance of the class, and click on it, a click event is raised for the...
6
by: steve bull | last post by:
I created a usercontrol class, RGBColorSpace, which is derived from an abstract class, ColorSpace, but when I try to click on the design panel for the control I get an error message "Unable to...
7
by: Colin Young | last post by:
I have a UserControl that contains a calendar control. The calendar is not raising events (month navigation, date selections, etc.). I've checked that the OnSelectionChanged event has a handler...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
0
by: Brad | last post by:
I added an Error event to a web usercontrol (ascx), but when an error is raised in the control it does not get called...only the Application_Error even in the global.asax gets called. The same...
1
by: Lin | last post by:
Hi All, I have a UserControl and in the UserControl I have a few controls (textbox buttons ect.) and I want to know how can I fire the "onchange" event (of the usercontrol) when the textbox in...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
2
by: Simon Verona | last post by:
I have a usercontrol with code in the "leave" event which updates the final data back into a database. This works fine except if I have a default "accept" button on a form and invoke it by...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
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...

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.