Web Control Events

A

Ahmzee

Hi All,

I am developing webpart for Sharepoint Portal Server.Webparts inherit
webcontrol and are similar to web custom controls.

The problem i am faing is that if i create controls (LinkButtons) in
the CreateChildControls Method it's click event works perfactly.

But if i create controls (LinkButtons) in the RenderWebPart Method it's
click event doesn't work....WHY ?

the sequence in which the events are executing is debugged to be

1 - CreateChildControls
2 - Control's Event
3 - RenderWebPart

I came to know in the click event what UI to Create so i can't use
CreateChildControls as it has already been executed so i want to to do
it in RenderWebpart.

For creating controls / UI am calling the same function from both
CreateChildControls and RenderWebPart, but it doesn't work in the
later.

plz Help
Ahmzee.
 
J

John Saunders

Hi All,

I am developing webpart for Sharepoint Portal Server.Webparts inherit
webcontrol and are similar to web custom controls.

The problem i am faing is that if i create controls (LinkButtons) in
the CreateChildControls Method it's click event works perfactly.

But if i create controls (LinkButtons) in the RenderWebPart Method it's
click event doesn't work....WHY ?

the sequence in which the events are executing is debugged to be

1 - CreateChildControls
2 - Control's Event
3 - RenderWebPart

I came to know in the click event what UI to Create so i can't use
CreateChildControls as it has already been executed so i want to to do
it in RenderWebpart.

You have to do these things in CreateChildControls.

Whenever something happens which invalidates the set of child controls, you
must set ChildControlsCreated to false. So, for instance, in your click
event, if you are going to change the UI, you have to set
ChildControlsCreated to false. This will cause CreateChildControls to be
executed the next time someone callse EnsureChildControls. At the worst,
this will happen just before PreRender.

John Saunders
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top