c# & autoeventwireup

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

So I set autoeventwireup=false in my aspx page. Now for some reason the
method below doesnt get executed. How do I get it to execute?

public partial class App_Fees_list_fees : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

InitControls();

}

protected void InitControls()

{

string[] keys = new string[1];

keys[0] = "feeid";

list.DataKeyNames = keys;

list.EmptyDataText = "Sorry, no fees were found in the database.";

pnl_list.Visible = true;

//pnl_details.Visible = false;

LoadData();

}



}

TIA!
 
The "some reason" would be that you set autoeventwireup=false.

You have to manually attach the handler for the Load event to the Page_Load
routine now that it's not being automatically done for you.
 
How do I manually attach the handler for the Load event? It would be nice if
you can provide some code samples and where to put it in the code behind
page?

TIA!

Marina Levit said:
The "some reason" would be that you set autoeventwireup=false.

You have to manually attach the handler for the Load event to the
Page_Load routine now that it's not being automatically done for you.

Hi all,

So I set autoeventwireup=false in my aspx page. Now for some reason the
method below doesnt get executed. How do I get it to execute?

public partial class App_Fees_list_fees : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

InitControls();

}

protected void InitControls()

{

string[] keys = new string[1];

keys[0] = "feeid";

list.DataKeyNames = keys;

list.EmptyDataText = "Sorry, no fees were found in the database.";

pnl_list.Visible = true;

//pnl_details.Visible = false;

LoadData();

}



}

TIA!
 
Thanks for Brians's input.

Hi Param,

for your case here, if turning on "autoeventwireup" is no possible, you can
programmatically regsiter the page's event handlers in constructor. e.g.

=======================

public partial class App_Fees_list_fees : System.Web.UI.Page

{

public App_Fees_list_fees()
{
this.Load += new EventHandler(Page_Load);
}


protected void Page_Load(object sender, EventArgs e)

{

if (!IsPostBack)

InitControls();

}
====================

If you have other event handlers for the page's events, you need to
manually register them also.


Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top