473,400 Members | 2,145 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,400 software developers and data experts.

How to find control from Page_Error event ?

Hello,

I would like to show an error message in a user control when an exception is
thrown.

This message should be built in Page_error or Application_error event and i
don't manage to reach a label contained in a user control from these events :

"lbl_error" is the ID of my label :

private void Page_Error(object sender, System.EventArgs e)
{

Exception objErr = Server.GetLastError().GetBaseException();
string error =
(((System.Web.UI.Page)sender).Controls[1].FindControl("lbl_error")).ID ;
Server.ClearError();

}

Any idea ?
Thanks,

Nov 18 '05 #1
2 2792
The Page_Error is in a base page ...

"fump75" wrote:
Hello,

I would like to show an error message in a user control when an exception is
thrown.

This message should be built in Page_error or Application_error event and i
don't manage to reach a label contained in a user control from these events :

"lbl_error" is the ID of my label :

private void Page_Error(object sender, System.EventArgs e)
{

Exception objErr = Server.GetLastError().GetBaseException();
string error =
(((System.Web.UI.Page)sender).Controls[1].FindControl("lbl_error")).ID ;
Server.ClearError();

}

Any idea ?
Thanks,

Nov 18 '05 #2
Hi fump:

I have some tips on using FindControl in this article:
http://odetocode.com/Articles/116.aspx

HTH,
--
Scott
http://www.OdeToCode.com

On Fri, 27 Aug 2004 00:35:01 -0700, fump75
<fu****@discussions.microsoft.com> wrote:
The Page_Error is in a base page ...

"fump75" wrote:
Hello,

I would like to show an error message in a user control when an exception is
thrown.

This message should be built in Page_error or Application_error event and i
don't manage to reach a label contained in a user control from these events :

"lbl_error" is the ID of my label :

private void Page_Error(object sender, System.EventArgs e)
{

Exception objErr = Server.GetLastError().GetBaseException();
string error =
(((System.Web.UI.Page)sender).Controls[1].FindControl("lbl_error")).ID ;
Server.ClearError();

}

Any idea ?
Thanks,


Nov 18 '05 #3

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

Similar topics

2
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
4
by: Alex Nitulescu | last post by:
Hi. I read about Page_Error and Application_Error. However, I provoke an error in a page but still Page_Error won't run. This is all the code I have left in my page: ...
4
by: Prince Mathew | last post by:
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...
1
by: Buddy Ackerman | last post by:
I have a page where users upload files. I have the maxRequestLength set and have created a Page_Error procedure to trap the error when someone load a file that is larger than the maxRequestLength....
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
2
by: Matt | last post by:
As the subject says... are Application_Error and Page_Error triggered by the same event? In other words, is there any error that could slip by Application_Error but be caught by Page_Error, or...
3
by: Carlo Razzeto | last post by:
Is there anyway to inline Page_Error type global error handling in an ASP.Net webpage? Currently I work on a very large web system where the entier web front end is contained in a single project...
1
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:...
2
by: Erik Lautier | last post by:
I've got Page_Error emailing me the message and stack trace when a server error is generated, but it doesn't always work. My Page_Error code: Sub Page_Error(ByVal src As Object, ByVal args As...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
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...
0
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,...
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...
0
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,...

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.