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

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

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

    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 Guest

  2. Similar Questions and Discussions

    1. Event Order
      Does the load event on the parent page occur after the create child controls event on a custom control?
    2. order of Event Handling and Posting Page_Load..?
      I am using datagrids with buttoncolumn etc. I am trying to understand the order of events. If a user clicks on a ButtonColumn button, what is the...
    3. order of event firing problem
      Hi all, Would really appreciate some help on this one! Am trying to make a multilingual site with a button to toggle between English and...
    4. coposite controls and events order
      Please, set this thread in its correct place. And sorry :-)
    5. Change the order of TAB
      When pressing the TAB key, the cursor will advance to another field in the form. But may I know how can I change the order of the cursor movement...
  3. #2

    Default Re: INamingContainer has change my controls event order.....

    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:
    [url]http://clariusconsulting.net/vga[/url]
    My profile: [url]http://aspnet2.com/mvp.ashx?vga[/url]


    "Alex Stevens" <alexstevens_nospam_@blueyonder_nospam_.co.uk> wrote in
    message news:dMbdd.84374$ay5.66108@fe1.news.blueyonder.co. uk...
    > 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] Guest

  4. #3

    Default Re: INamingContainer has change my controls event order.....

    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:
    > [url]http://clariusconsulting.net/vga[/url]
    > My profile: [url]http://aspnet2.com/mvp.ashx?vga[/url]
    >
    >
    > "Alex Stevens" <alexstevens_nospam_@blueyonder_nospam_.co.uk> wrote in
    > message news:dMbdd.84374$ay5.66108@fe1.news.blueyonder.co. uk...
    > > 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 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139