Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question Page_Load not doing anything?

    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?

  • #2
    New to the CF scene
    Join Date
    Apr 2004
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    this.Load += new System.EventHandler(this.Page_Load);
    Do you have this in your InitializeComponent() (in your code-behind) ?

  • #3
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post
    Yes....

    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..?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •