Dynamicly loaded User Control events in a Placeholder

M

MikeM

I am having a problem of receiving UserControl events which gets dynamicly loaded within a Placeholder on a main.aspx page. If I explictly place "myControl" on the main.aspx page I can receive events and act on them, but when I dynamicly load "myControl" within a Placeholder in main.aspx.vb code-behind I can not find a way to get the events for these controls contained within the Placeholder. I am using the Placeholder on the main.aspx page for layout and because the number of usercontrols loaded will vary.

Any help on this would be greatly appreciated

Thanks
Mike
 
C

ccallen

Mike,

Did you get this working yet?

I am doing the same thing as you, although I ran into a different set of
problems
(mostly compiler errors). Once I worked through the compiler errors the
events worked fine (both in the placeholder method and the regular way).

The pagelet samples in the .net sdk has an example of doing this using the
non-code behind method (Pagelet7). There is vstudio tree with a code behind
versions of the pagelet samples, however they do not use a PlaceHolder, they
add to the Page object itself.

To get code-behind + PlaceHolder approach to work, I got the non-codebehind
version working. Created a new webform and web user control, pasted the code
into the codebehind files. I had to add a reference to the place holder in
the web form's codebehind module. The event handlers also had to be prefixed
with public as well.

I can post my example code if you (or anyone else) are insterested.

ccallen

MikeM said:
I am having a problem of receiving UserControl events which gets dynamicly
loaded within a Placeholder on a main.aspx page. If I explictly place
"myControl" on the main.aspx page I can receive events and act on them, but
when I dynamicly load "myControl" within a Placeholder in main.aspx.vb
code-behind I can not find a way to get the events for these controls
contained within the Placeholder. I am using the Placeholder on the
main.aspx page for layout and because the number of usercontrols loaded will
vary.
 
M

MikeM

Yes, I found that I needed to add an EventHandler in the UserControl code behind file and add a handler on the main.aspx.vb codebehind for the dynamicly added usercontrol

Thanks
Mike

----- ccallen wrote: ----

Mike

Did you get this working yet

I am doing the same thing as you, although I ran into a different set o
problem
(mostly compiler errors). Once I worked through the compiler errors th
events worked fine (both in the placeholder method and the regular way)

The pagelet samples in the .net sdk has an example of doing this using th
non-code behind method (Pagelet7). There is vstudio tree with a code behin
versions of the pagelet samples, however they do not use a PlaceHolder, the
add to the Page object itself

To get code-behind + PlaceHolder approach to work, I got the non-codebehin
version working. Created a new webform and web user control, pasted the cod
into the codebehind files. I had to add a reference to the place holder i
the web form's codebehind module. The event handlers also had to be prefixe
with public as well

I can post my example code if you (or anyone else) are insterested

ccalle

MikeM said:
I am having a problem of receiving UserControl events which gets dynamicl
loaded within a Placeholder on a main.aspx page. If I explictly plac
"myControl" on the main.aspx page I can receive events and act on them, bu
when I dynamicly load "myControl" within a Placeholder in main.aspx.v
code-behind I can not find a way to get the events for these control
contained within the Placeholder. I am using the Placeholder on th
main.aspx page for layout and because the number of usercontrols loaded wil
vary
 
J

Jonathan Roberts

I would be interested to see your code, as I have being trying to get
dynamically added usercontrol events initiating parent Webform
eventhandlers.
If that all makes sense.
Regards Jonathan Roberts
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top