c# & autoeventwireup

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!
 
M

Marina Levit [MVP]

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

Guest

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!
 
S

Steven Cheng[MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top