S
Stephen Miller
Hi,
I am new to web controls so please forgive me if my terminology is not
100%!
I am attempting to develop a composite control, based heavily on the
Chapter 16 sample code in James Henry's "Developing .NET Custom
Controls and Designers using C#" (see
http://www.bluevisionsoftware.com/WebSite/BookInfo.aspx?ID=7 ).
The Control is designed to emulate a windows tab control by overriding
the Render method to sending a customized HtmlTable.
The control implements IpostBackDataHandler (with
RaisePostDataChangedEvent & LoadPostData methods),
IpostBackEventHandler (with RaisePostBackEvent method) and
InamingContainer.
This works fine, and I am very happy with the results, however when I
nest any server controls that require PostBack, the nested controls
fail to raise events.
The ASPX for the custom control takes the following form. As an
example, a standard Button control has been placed between the second
tab's <cc1:Tab></cc1:Tab> tags.
<cc1:TabControl id="myTab" runat="server">
<cc1:Tab headertext="Tab1">First tab's content goes here</cc1:Tab>
<cc1:Tab headertext="Tab2">
Second tab's content includes a nested control:
<asp:Button id="cmdTest" runat="server" Text="Click me!">
</asp:Button>
</cc1:Tab>
<cc1:Tab headertext="tab3">Third tab's content goes here</cc1:Tab>
</cc1:TabControl>
In the codebehind, a function 'cmdTest_Click' has been declared to
handle the 'cmdTest.Click' event. It is expected that clicking the
button should call this function, however this doesn't happen.
Interestingly, the page appears to make a round-trip to the server, it
just fails to call events bound to the nested control. If the button
is moved outside the custom control, it behaves as expected.
What should I do to enable nested controls to generate their own
events? If someone could post some code snippits, I would be much
obliged!
Thanks,
Stephen
I am new to web controls so please forgive me if my terminology is not
100%!
I am attempting to develop a composite control, based heavily on the
Chapter 16 sample code in James Henry's "Developing .NET Custom
Controls and Designers using C#" (see
http://www.bluevisionsoftware.com/WebSite/BookInfo.aspx?ID=7 ).
The Control is designed to emulate a windows tab control by overriding
the Render method to sending a customized HtmlTable.
The control implements IpostBackDataHandler (with
RaisePostDataChangedEvent & LoadPostData methods),
IpostBackEventHandler (with RaisePostBackEvent method) and
InamingContainer.
This works fine, and I am very happy with the results, however when I
nest any server controls that require PostBack, the nested controls
fail to raise events.
The ASPX for the custom control takes the following form. As an
example, a standard Button control has been placed between the second
tab's <cc1:Tab></cc1:Tab> tags.
<cc1:TabControl id="myTab" runat="server">
<cc1:Tab headertext="Tab1">First tab's content goes here</cc1:Tab>
<cc1:Tab headertext="Tab2">
Second tab's content includes a nested control:
<asp:Button id="cmdTest" runat="server" Text="Click me!">
</asp:Button>
</cc1:Tab>
<cc1:Tab headertext="tab3">Third tab's content goes here</cc1:Tab>
</cc1:TabControl>
In the codebehind, a function 'cmdTest_Click' has been declared to
handle the 'cmdTest.Click' event. It is expected that clicking the
button should call this function, however this doesn't happen.
Interestingly, the page appears to make a round-trip to the server, it
just fails to call events bound to the nested control. If the button
is moved outside the custom control, it behaves as expected.
What should I do to enable nested controls to generate their own
events? If someone could post some code snippits, I would be much
obliged!
Thanks,
Stephen