开发者

Ajax TabContainerTabPanels Break postbacks

Hey guys check this out ...

<asp:TabContainer ID="jkhgjkgh" runat="server">
    <asp:TabPanel ID="jkkljhgh" runat="server" HeaderText="sdkl;fgjl;kgjdf">
        <ContentTemplate>
            <asp:Button ID="jhgkjgh" runat="server" Text="Button" onclick="Button1_Click" />
        </ContentTemplate>
    </asp:TabPanel>
    <asp:TabPanel ID="jkgh" runat="server" HeaderText="gjdkl;gjdf;g" Visible="false">
        <ContentTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="dropDownSelect">
                <asp:ListItem Text="test" />
                <asp:ListItem Text="test" />
                <asp:ListItem Text="test" />
                <asp:ListItem Text="test" />
            </asp:DropDownList> 
        </ContentTemplate>
    </asp:TabPanel>

nothing crazy ... just a tabcontainer with a couple of panels on it the second is hidden.

now we go to the code behind ...

    protected void Button1_Click(object sender, EventArgs e)
    {
        TabPanel p = new TabPanel();

        p.ContentTemplate = jkgh.ContentTemplate;

        jkhgjkgh.Tabs.Add(p);
    }

    protected void dropDownSelect(object sender, EventArgs e)
    {
        int i = 0;
    }

Here's where it all goes horribly wrong ...

I cli开发者_开发问答ck the button on the first tab panel to create a new tab that has the template defined in my hidden panel, i then go to that panel and change the selection in the drop down ....

It does a postback but the drop down event is never raised ....

Any ideas ???


The problem is that you cant dynamically copy the hidden templated tabpanel and add a new one in to the collection. Apparently the tabcontainer control doesn't allow for this without a lot of "hacking around".

I'm not entirely sure why but it seems that ITemplate types don't clone well for event handling.


I think it might be because your TabContainer does not have AutoPostBack set to true.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜