try to create my own server control

G

George Ter-Saakov

I am trying to create my own server control "Tab"

So i have following classes

---------------------------------------------

public class TabsView : WebControl, INamingContainer
{
private TabPageCollection _tabs;
.....
}

public class TabPageCollection : ControlCollection
{...}

public class TabPage : WebControl, INamingContainer
{...}
---------------------------------------
Use

<cc1:TabsView ID="TabsView1" runat="server" >
<cc1:TabPage runat="server" ID="t1" TabName="T1">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Click Me"
OnClick="Serverclick" />
</cc1:TabPage>
<cc1:TabPage runat="server" ID="t2" TabName="T2">
Test&nbsp;<br />
</cc1:TabPage>
</cc1:TabsView>
-------------------------------------------

Everything renders fine.
The problem i have with Postback. For whatever reason when i click Button2
POST happens but Serverclick is not called. Nor Textbox2 retains it value.

why is that?

thanks
George.
 
G

George Ter-Saakov

Problem solved.
Do not use ControlCollection. It does not register controls with the page.
Write your own collection that will add controls to the Controls collection
when control is added by ASP.NET parser.

George.
 

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

Top