CompositeControl's children are interleaving with other controls on the page

E

estebistec

Hello,

I've developed a CompositeControl in C# for ASP.NET 2.0. In this
control I am simulating Edit and View modes by hiding or showing
appropriate controls (setting Control.Visible). Basically I'm
simulating the functionality of the DetailsView or a GridView cell,
except that my data is dynamic (variable number of fields), so I can't
just use those. So I have custom edit and view controls for this
dynamic data and I render one of those two based on the current mode of
the control. I also render an "Edit" button in view mode and "Cancel"
and "Save" buttons in edit mode. As I said I just change the visibility
of controls appropriately, so I just render them all in the overrie of
RenderContents() like so:

this.ViewControl.RenderControl(writer);
this.EditorControl.RenderControl(writer);
writer.WriteBreak();
this.EditButton.RenderControl(writer);
this.SaveButton.RenderControl(writer);
this.CancelButton.RenderControl(writer);

This works fine in view-mode, but when edit-mode is entered, the Save
and Cancel buttons are rendered BEFORE the EditorControl, and after
those another control from the page I'm testing on also appears before
the EditorControl. So not only is it reversing the order of the edit
buttons and control, but it is interleaving the rendering of another
control from the page, in-between children from this control.
Otherwise, all of the individual child controls work and do what
they're supposed to, successfully editing my dynamic data, but the
rendering order is sure to confuse users.

Has anybody seen anything like this and/or have clues as to what may
fix it? Thanks.
 
E

estebistec

Ug, okay, so I should have looked into simpler aspects of this problem
before posting. The problem was just that I had neglected to close a
table row (</tr>) in the RenderContents method of the EditorControl.
I've been very busy so I had just abandoned the problem after that post
until today. So, moral of the story, don't neglect to check the HTML
(not just the code!) when layout or rendering is going bonkers...

shamefully yours
/S
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top