HELP! Child controls of child controls not visible to web app

L

lisa

I have a custom server control. It's a TabControl. It's really cool,
actually. Looks just like a standard VB6 TabControl. It lets you set
the number of tabs per row, and automatically renders itself properly
(even client side) just like a regular multirow TabControl.

When I put on onto a page, it looks like this:

<fw:TabControl id="TabControl1" runat="server">
<fw:Tab ID="TabControl7__ctl0" Text="Tab 1">
test
</fw:Tab>
<fw:Tab ID="TabControl7__ctl1" Text="Tab 2">
<asp:button id="Button1" runat="server" Text="Button">
<asp:checkbox id="CheckBox1" runat="server" Text="testme" />
</fw:Tab>
</fw:TabControl>

It's a TabControl with two Tabs in it, which are members of a
TabCollection. I put simple test onto the first Tab (manually, in HTML
view, which is the only way to do it), and a Button and a CheckBox on
the second Tab.

These were not added programmatically. In fact, what I did was drag
the controls onto the WebForm, and then go into HTML view and move the
resulting code into the Tab. By doing this, I made sure that VS.NET
put the Protected WithEvents statements into OnInit.

The first problem that I ran into was that if I checked the CheckBox
and then did a postback, the CheckBox cleared. Or if I checked it in
the HTML so that it came up that way to begin with, and then unchecked
it, a postback would set it back to checked. Basically, my TabControl
was rendering the stuff that was set in the HTML and ignoring any
postback changes to the contents of the Tabs.

Fine. So I found a workaround for that. I added onpropertychanged
events to all the children before rendering, added a hidden control to
my TabControl, and made sure it contained a list of all children of
Tabs which had changed. Then on postback, I grabbed that control from
Request.Form and raised the postbackdata event on each control that had
changed. Kludgy and nasty, but it worked.

But it didn't change the underlying problem, which was that these child
controls aren't seen by the web app. If I click on that Button on the
second Tab, Button1_OnClick does not fire. The page clearly posts
back, but the event doesn't fire.

I can't think of how to get the Page to recognize those controls. I
can't do Me.Controls.Add(whatever), because if I run in debug, the
controls are already there. Sort of. If I do:

?Me.TabControl.Tabs(1).Controls(0).ID

in the Command Window, it gives me "Button1". So it definitely sees
the controls in some way or another.

I'm obviously missing something. What I don't know is if it's
something trivial and stupid that I can just fix with a few keystrokes,
or if it's something deeper than that.

To repeat, I don't add these controls in the code at all. I just typed
them into the HTML between the beginning and ending tags of the Tab.
The same way I would with Microsoft's MultiPage control. And I've been
through the source code for that control and can't find anything that
would explain why it doesn't have the same problem as my TabControl.

Does anyone have any suggestions?

Thanks,
Lisa
 

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

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,054
Latest member
LucyCarper

Latest Threads

Top