asp.net - In WebForms, why does my anonymous event handler not get called when added after OnLoad? -
i have asp.net webforms page several buttons added programmatically this: private void addexportbutton(control control, action clickaction) { linkbutton exportbutton = new linkbutton { text = "export", enableviewstate = false /*buttons recreated on each postback anyway.*/ }; exportbutton.click += (sender, e) => clickaction(); control.controls.add(exportbutton); } now works, long addexportbutton() method called along path onload() or onpreload() method. not fire handler action however, when addexportbutton() called onloadcomplete() method. i add/create buttons when event handler (coming dropdown) gets called. happens after onload(), break code. why this, , how can use anonymous methods event handlers in case? see nice cheat sheet asp.net page lifecycle léon andrianarivony more info order of page/control creation. in page life cycle, internal raisepostbackevent method (which raises ...