Creating an object in page_init

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

Mark Rae

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

=?ISO-8859-1?Q?G=F6ran_Andersson?=

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?
 

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,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top