AutoPostBack not triggering Page_Load

1k views Asked by At

I have an asp ddl setup like this:

<asp:DropDownList ID="attendeeList2" runat="server" AutoPostBack="true" CssClass="tripRegistrationItem" />

c#:

private void attendeeList2_SelectedIndexChanged(object sender, EventArgs e)
{
    _mission = new Mission(Int32.Parse(tripList.SelectedValue));
    person = new Person(int.Parse(attendeeList2.SelectedValue));
    attendeeLabel.Text = person.FullName.ToString();
    ClearInputs(tripRegistrationWizard.WizardSteps[1].Controls);
    LoadAttributes();
    SetInfo();            
    }

and:

private void InitializeComponent()
{            
    attendeeList.SelectedIndexChanged += new EventHandler(attendeeList_SelectedIndexChanged);
    attendeeList2.SelectedIndexChanged += new EventHandler(attendeeList2_SelectedIndexChanged);
}

What I am experiencing is that the attendeeList2_SelectedIndexChanged does indeed fire when the selected item of the DDL is changed, and the code within the method is executed, however a Page_Load, Page_Init, Page_PreRender... are NOT raised. It is almost like it isn't doing a true PostBack, yet it is running the code. I am needing to do some things in the Page_PreRender in that OnChange event, but can't figure out how to pull it off.

Can someone explain to me what I am doing wrong?

Thank you!

EDIT:

Here is the code that calls InitializeComponent():

override protected void OnInit(EventArgs e)
{
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
}

EDIT 2: I just realized that the client side control I am working with is inside an Update Panel. It appears that when the control is within an Update Panel, it simply does an AJAX refresh, never raising the Page_Load, Page_Init... Once I pulled the control out of the update panel, it now triggers a full Post Back as I was expecting. Not sure why I couldn't find that tidbit of info while searching around, but now I know.

1

There are 1 answers

0
dipsiecamila On

Please try at the page directive to add:

autoeventwireup="true"

some like:

<%@ page language="C#" autoeventwireup="true" codefile="yourpage.aspx.cs" inherits="yourclass"%>