How to find control from Page_Error event ?

G

Guest

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,
 
S

Scott Allen

Hi fump:

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

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

The Page_Error is in a base page ...

fump75 said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top