Ajax TabContainerTabPanels中断回发 [英] Ajax TabContainerTabPanels Break postbacks
问题描述
大家看看...
<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 click 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 ....
任何想法???
推荐答案
问题是您无法动态复制隐藏的模板化选项卡,并向其中添加一个新的选项卡. 显然,tabcontainer控件在没有大量黑客攻击"的情况下是不允许这样做的.
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".
我不确定为什么会这样,但似乎ITemplate类型不能很好地克隆以进行事件处理.
I'm not entirely sure why but it seems that ITemplate types don't clone well for event handling.
这篇关于Ajax TabContainerTabPanels中断回发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!