Creating an object in page_init

  • Thread starter Thread starter Suma.Amar
  • Start date Start date
S

Suma.Amar

Hi,
I have a problem in web page load event.

I'm creating a controller class in the page_load event of a web page.
That class will have the code for the event handling of all the
controls in the web page. Now my problem is whenever the page is
reloaded, the controller class is recreated. I tried session also to
check whether it is already available. It works fine but only thing is
it is not assigning the event handlers to the page controls.

Can anyone help on this.

Regards,
Suma.
 
I'm creating a controller class in the page_load event of a web page.
That class will have the code for the event handling of all the
controls in the web page. Now my problem is whenever the page is
reloaded, the controller class is recreated. I tried session also to
check whether it is already available. It works fine but only thing is
it is not assigning the event handlers to the page controls.

Can anyone help on this.

As your subject says, you need to create dynamic controls in Page_Init or
Page_PreInit if you want their events to be wired up successfully...
 
Hi,
I have a problem in web page load event.

I'm creating a controller class in the page_load event of a web page.
That class will have the code for the event handling of all the
controls in the web page. Now my problem is whenever the page is
reloaded, the controller class is recreated. I tried session also to
check whether it is already available. It works fine but only thing is
it is not assigning the event handlers to the page controls.

Can anyone help on this.

Regards,
Suma.

As the controls of the page is created from scratch every time the page
is loaded, you have to reregister all events every time.

Is there any reason for having the event handlers in a separate class
instead of in the class for the page?
 
Back
Top