INamingContainer has change my controls event order.....

Discussion in 'ASP .Net Building Controls' started by Alex Stevens, Oct 19, 2004.

  1. Alex Stevens

    Alex Stevens Guest

    Hi All,

    I have built a composite user web control and I've NOT implemented
    INamingContainer.
    It does implement IPostBackDataHandler to retrieve information entered into
    the controls when the host page is submitted.

    In the controls LoadPostData event, I retrieve the information entered and
    act upon.
    The information entered affects the way the control is rendered, so in the
    controls CreateChildControls event, I build the objects as they should be
    based, on the information the user entered and submitted.

    Once I put the control onto a web form it worked fine in isolation, but once
    I added other controls to the host page it fell over with the error:
    "Multiple controls with the same ID '_ctl1' were found. FindControl requires
    that controls have unique IDs."

    Fair enough, so I go to my control and Implement INamingContainer so that it
    prefixes all the controls within my user control with the main controls
    name.
    However, this effected another change. The LoadPostData event is now
    executed after the CreateChildControls event. This means that I can't render
    the control based on what was retrieved in the LoadPostData event????

    This seems like a fairly sensible thing to do, so why when implementing
    INamingContainer do the control base events change order???
    How do I render the controls objects based on information retrieved in the
    LoadPostData event????

    Thanks

    Alex
     
    Alex Stevens, Oct 19, 2004
    #1
    1. Advertising

  2. Hi Alex,

    When you need to re-create children controls because of the value of a
    posted field, some event ocurrence, or anything else, then you can simply do
    so by setting the ChildControlsCreate property to false. This will flags the
    children as not created so next time ASP.NET needs to handle children
    control will notice them and recreate them, and this recreation will happen
    now with any updated value you would have set before.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://clariusconsulting.net/vga
    My profile: http://aspnet2.com/mvp.ashx?vga


    "Alex Stevens" <alexstevens_nospam_@blueyonder_nospam_.co.uk> wrote in
    message news:dMbdd.84374$...
    > Hi All,
    >
    > I have built a composite user web control and I've NOT implemented
    > INamingContainer.
    > It does implement IPostBackDataHandler to retrieve information entered
    > into
    > the controls when the host page is submitted.
    >
    > In the controls LoadPostData event, I retrieve the information entered and
    > act upon.
    > The information entered affects the way the control is rendered, so in the
    > controls CreateChildControls event, I build the objects as they should be
    > based, on the information the user entered and submitted.
    >
    > Once I put the control onto a web form it worked fine in isolation, but
    > once
    > I added other controls to the host page it fell over with the error:
    > "Multiple controls with the same ID '_ctl1' were found. FindControl
    > requires
    > that controls have unique IDs."
    >
    > Fair enough, so I go to my control and Implement INamingContainer so that
    > it
    > prefixes all the controls within my user control with the main controls
    > name.
    > However, this effected another change. The LoadPostData event is now
    > executed after the CreateChildControls event. This means that I can't
    > render
    > the control based on what was retrieved in the LoadPostData event????
    >
    > This seems like a fairly sensible thing to do, so why when implementing
    > INamingContainer do the control base events change order???
    > How do I render the controls objects based on information retrieved in the
    > LoadPostData event????
    >
    > Thanks
    >
    > Alex
    >
    >
     
    Victor Garcia Aprea [MVP], Oct 23, 2004
    #2
    1. Advertising

  3. I have a similar situation as Alex did, but when I tried setting
    ChildControlsCreated=false, two instances of the object were rendered in the
    browser. A before and an after. Where should this call be made?

    "Victor Garcia Aprea [MVP]" wrote:

    > Hi Alex,
    >
    > When you need to re-create children controls because of the value of a
    > posted field, some event ocurrence, or anything else, then you can simply do
    > so by setting the ChildControlsCreate property to false. This will flags the
    > children as not created so next time ASP.NET needs to handle children
    > control will notice them and recreate them, and this recreation will happen
    > now with any updated value you would have set before.
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://clariusconsulting.net/vga
    > My profile: http://aspnet2.com/mvp.ashx?vga
    >
    >
    > "Alex Stevens" <alexstevens_nospam_@blueyonder_nospam_.co.uk> wrote in
    > message news:dMbdd.84374$...
    > > Hi All,
    > >
    > > I have built a composite user web control and I've NOT implemented
    > > INamingContainer.
    > > It does implement IPostBackDataHandler to retrieve information entered
    > > into
    > > the controls when the host page is submitted.
    > >
    > > In the controls LoadPostData event, I retrieve the information entered and
    > > act upon.
    > > The information entered affects the way the control is rendered, so in the
    > > controls CreateChildControls event, I build the objects as they should be
    > > based, on the information the user entered and submitted.
    > >
    > > Once I put the control onto a web form it worked fine in isolation, but
    > > once
    > > I added other controls to the host page it fell over with the error:
    > > "Multiple controls with the same ID '_ctl1' were found. FindControl
    > > requires
    > > that controls have unique IDs."
    > >
    > > Fair enough, so I go to my control and Implement INamingContainer so that
    > > it
    > > prefixes all the controls within my user control with the main controls
    > > name.
    > > However, this effected another change. The LoadPostData event is now
    > > executed after the CreateChildControls event. This means that I can't
    > > render
    > > the control based on what was retrieved in the LoadPostData event????
    > >
    > > This seems like a fairly sensible thing to do, so why when implementing
    > > INamingContainer do the control base events change order???
    > > How do I render the controls objects based on information retrieved in the
    > > LoadPostData event????
    > >
    > > Thanks
    > >
    > > Alex
    > >
    > >

    >
    >
    >
     
    Kasabaarde Sumta, Dec 14, 2004
    #3
    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. Alex Stevens
    Replies:
    0
    Views:
    412
    Alex Stevens
    Oct 19, 2004
  2. TS
    Replies:
    5
    Views:
    428
    =?Utf-8?B?VFM=?=
    Jul 20, 2007
  3. TS
    Replies:
    4
    Views:
    525
    Walter Wang [MSFT]
    Aug 1, 2007
  4. Greg Woods
    Replies:
    2
    Views:
    1,152
    Peter Bucher [MVP]
    Apr 1, 2008
  5. Alex Stevens

    INamingContainer has change my controls event order.....

    Alex Stevens, Oct 19, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    122
    Alex Stevens
    Oct 19, 2004
Loading...

Share This Page