Ajax TabContainerTabPanels 中断回发
嘿,伙计们,看看这个……
<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>
没什么疯狂的……只是一个带有几个面板的选项卡容器,第二个面板被隐藏了。
现在我们转到后面的代码...
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;
}
这就是一切严重错误的地方...
我单击第一个选项卡面板上的按钮来创建一个新选项卡,该选项卡在我的隐藏面板中定义了模板,然后转到该面板并更改下拉列表中的选择....
它会进行回发,但下拉事件永远不会引发....
有什么想法吗???
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 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 ....
Any ideas ???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是您无法动态复制隐藏的模板化选项卡面板并将新的选项卡面板添加到集合中。
显然,如果没有大量的“修改”,选项卡容器控件不允许这样做。
我不完全确定为什么,但似乎 ITemplate 类型不能很好地克隆事件处理。
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.
我认为这可能是因为您的 TabContainer 没有将 AutoPostBack 设置为 true。
I think it might be because your TabContainer does not have AutoPostBack set to true.