Shaitan00 Posted February 8, 2005 Posted February 8, 2005 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"> <asp:ListItem>0</asp:ListItem> </asp:dropdownlist> 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? Quote
HJB417 Posted February 8, 2005 Posted February 8, 2005 can you post the entire html, make sure the 'autoeventwireup' isn't set to false. You can also try protected override void OnLoad(object sender) { lblSelected.Text = "ENTERED PAGE_LOAD"; } Quote
ombun2 Posted February 14, 2005 Posted February 14, 2005 just skimming through your question...what are you writing your code in?: Visual Studio.Net? Starting a new ASP.NET project in that putting a label on the form and setting the text to something in the page load, should DEFINITELY work there. What caught my eye in what you wrote however was "but I can't DEBUG ASP.NET web application so it is kind of hard" Do you mean that when you press F5 you get errors of some kind, even for a blank new app? I've had this problem before, I've installed several insances of VS.Net and I've noticed that on WinXP(i don't know about other OSs) it would give me such an error. I've uninstalled it and reinstalled it several times until i've just got angry and uninstalled absolutely everything related to .net (including the framework) that came with windows. After that I installed VS.NEt again, this time letting it install it's own copy of the framework and everything was handydandy. Your problem seems to be too simple to be some programming mistake so I think it might be some M$ thingie. hope it helped Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.