Saturday, 15 August 2015

c# - LoadControl in a static scriptmethod does not adhere page lifecycle (Init event is not raised) -



c# - LoadControl in a static scriptmethod does not adhere page lifecycle (Init event is not raised) -

i'm using scriptmethod called javascript. within method seek utilize loadcontrol programmatically control.

i'm adding command current ihttphandler (httpcontext.current.handler) instance of page contains (static) scriptmethod. instance add together command loaded using loadcontrol init event of command never raised.

is possible utilize loadcontrol in scriptmethod while adhering page lifecycle?

you'll need execute page contains command relevant events fire:

static void rendercontrolto(string pathtocontrol, textwriter writer) { var page = new page(); var command = page.loadcontrol(pathtocontrol); page.controls.add(control); httpcontext.current.server.execute(page, writer, false); }

c# asp.net webforms page-lifecycle

No comments:

Post a Comment