AutoEventWireUp Problem

S

Sam Solomon

Dear All,

I am using Page_Error event in my aspx page to generate an error. Below is
my code in my Page_Error event:


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

{

Response.Write("Error:\n");

Exception ex = Server.GetLastError();

Trace.Write("Message",ex.Message);

Trace.Write("Source",ex.Source);

Trace.Write("Stack Trace",ex.StackTrace);

Response.Write("Sorry, an error was encountered.");

Context.ClearError();

}

However the error is not generated because AutoEventWireup property is set
to "false". When I set the AutoEventWireupto "true" is can see the error. I
want to know the reason behind this whats AutoEventWireup got to do with
Page_Error event. . How are they both co-related.

Any help would be greatly appreciated

cheers,

Sam Solomon
 
K

Keith Patrick

In ASP.Net 1.1, those methods were named by convention, but the templates
for usercontrols/pages would put in the wireup for you by overriding OnInit
and saying Page.Load += new ....(this.Page_Load); AutoEventWireUp is a
means of doing that automatically by the page upon initialization. If that
value is true, on init, a page checks for Page_<event>, and if it has been
defined in the code, an event handler will wrap it.
 

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
474,262
Messages
2,571,049
Members
48,769
Latest member
Clifft

Latest Threads

Top