Dynamicly loaded User Control events in a Placeholder

Discussion in 'ASP .Net Building Controls' started by MikeM, Apr 9, 2004.

  1. MikeM

    MikeM Guest

    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
    MikeM, Apr 9, 2004
    #1
    1. Advertising

  2. MikeM

    ccallen Guest

    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" <> wrote in message
    news:...
    > 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
    ccallen, Apr 12, 2004
    #2
    1. Advertising

  3. MikeM

    MikeM Guest

    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" <> wrote in messag
    news:..
    > 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
    >> Any help on this would be greatly appreciated
    >> Thanks

    > Mik
    MikeM, Apr 19, 2004
    #3
  4. 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
    "ccallen" <> wrote in message news:<>...
    > 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" <> wrote in message
    > news:...
    > > 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
    Jonathan Roberts, Apr 25, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. keith
    Replies:
    9
    Views:
    2,104
    Graham Underwood
    Aug 8, 2008
  2. nail

    Build control in a placeholder or like a placeholder

    nail, Sep 10, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    325
  3. Micha³ Januszczyk

    Getting values entered into (dynamicly loaded control)

    Micha³ Januszczyk, Mar 9, 2005, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    120
    Mantas Miliukas
    Mar 10, 2005
  4. dotNet

    Problem with dynamicly added buttons in PlaceHolder

    dotNet, Feb 15, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    153
    dotNet
    Feb 15, 2005
  5. Micha³ Januszczyk

    Getting values entered into (dynamicly loaded control)

    Micha³ Januszczyk, Mar 9, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    111
Loading...

Share This Page