View Full Version : Page_Load not doing anything?

02-08-2005, 09:57 AM
Quick question: I had always assumed the Page_Load was like the Form_Load event for windows applications and therefore was run when loaded, however
I find myself contradicted when I realized nothing I ever place in my Page_Load section ever did anything.

Simple example (and I have tried many, but I can't DEBUG ASP.NET web application so it is kind of hard):
private void Page_Load(object sender, System.EventArgs e)
// Put user code to initialize the page here
lblSelected.Text = "ENTERED PAGE_LOAD";

However when I load the page my label does not display this text, can anyone explain to me why the page_load is not loading?
Am I supposed to indicate somewhere that I want it to? Is there something missing/wrong? Something in the .aspx file?
Nothing (including accessing databases) seems to run at all...

I encounter a similar issue with my dropdown list boxes, I have the following code:
<asp:dropdownlist id="ddlHour" OnSelectedIndexChanged="ddlHour_SelectedIndexChanged" runat="server">

public void ddlHour_SelectedIndexChanged(object sender, System.EventArgs e)
// Select Hour
lblDateSelected.Text = "HOURS";

In this case also my Label never changes to HOURS when I select 0 from my DropDrown choice and thus I can only assume this function is not being called. Or is there something else? Something fundamental I am missing?

02-08-2005, 06:05 PM
this.Load += new System.EventHandler(this.Page_Load);

Do you have this in your InitializeComponent() (in your code-behind) ?

02-08-2005, 08:07 PM

I changed the AutoEventWireup="false" to "true" and now it works great..
Any clue why? I thought all the wiring I needed to do was done..?