Ask a Question related to ASP.NET Building Controls, Design and Development.
-
Alex Stevens #1
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
-
Event Order
Does the load event on the parent page occur after the create child controls event on a custom control? -
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... -
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... -
coposite controls and events order
Please, set this thread in its correct place. And sorry :-) -
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... -
Victor Garcia Aprea [MVP] #2
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
-
Kasabaarde Sumta #3
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



Reply With Quote

