G
gnewsgroup
I know that enough has been written/talked about AutoEventWireup.
I've read the MSDN documentation about AutoEventWireup, which turns
out to be very brief.
I've also googled and read quite many articles/conversations about
this topic. I am still confused. Here are my questions:
1. Is it the case that only Page_* (e.g. Page_Load, Page_Init,
Page_PreRender, etc.) events are relevant with regard to
AutoEventWireup? In other words, this has nothing to do with, for
example, the Click event of a Button?
2. I created a very simple application, whose code-behind looks like
this:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("hola, and how is it going?");
}
// The ID of the Button is btnSubmit in the aspx page.
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblMessage.Text = TextBox1.Text;
}
}
If I set AutoEventWireup=false, Page_Load is not executed and I don't
see "hola, and how is it going?" in the browser. This message shows
up when AutoEventWireup=true.
This is understood.
But, then * with AutoEventWireup=false *, how do I manually wire up
Page_Load to the Load event? I tried adding the following right
before the Page_Load method:
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
The "hola, and how is it going?" message still does not show up in the
browser. I must not be doing the right thing, please kindly advise.
Thanks.
I have more questions to come regarding AutoEventWireup.
I've read the MSDN documentation about AutoEventWireup, which turns
out to be very brief.
I've also googled and read quite many articles/conversations about
this topic. I am still confused. Here are my questions:
1. Is it the case that only Page_* (e.g. Page_Load, Page_Init,
Page_PreRender, etc.) events are relevant with regard to
AutoEventWireup? In other words, this has nothing to do with, for
example, the Click event of a Button?
2. I created a very simple application, whose code-behind looks like
this:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("hola, and how is it going?");
}
// The ID of the Button is btnSubmit in the aspx page.
protected void btnSubmit_Click(object sender, EventArgs e)
{
lblMessage.Text = TextBox1.Text;
}
}
If I set AutoEventWireup=false, Page_Load is not executed and I don't
see "hola, and how is it going?" in the browser. This message shows
up when AutoEventWireup=true.
This is understood.
But, then * with AutoEventWireup=false *, how do I manually wire up
Page_Load to the Load event? I tried adding the following right
before the Page_Load method:
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
The "hola, and how is it going?" message still does not show up in the
browser. I must not be doing the right thing, please kindly advise.
Thanks.
I have more questions to come regarding AutoEventWireup.