ajaxtoolkit回发问题
我正在开发一个项目。但是我有一个问题。基本上,我正在使用 ajaxtoolkit tabcontainer。假设我创建了 2 个选项卡。让我们称它们为 tab1、tab2。在 tab1 中有一个按钮和文本框。当我单击时按钮,我正在文本框中写入一些文本。然后我动态创建一个选项卡。假设它称为“tab3”。问题是当我单击 tab1 中的按钮时,tab3 消失。我怎样才能防止这种情况发生?
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true"
Height="273px" Width="1050px">
<asp:TabPanel runat="server" HeaderText="tab1" ID="tab1">
<ContentTemplate>
选项卡2
这是我在函数中添加新选项卡的位置:
AjaxControlToolkit.TabPanel tp = new AjaxControlToolkit.TabPanel();
tp.HeaderText = "tab3";
tp.ContentTemplate = Page.LoadTemplate("WebUserControl1.ascx");
tp.ID = "tab3";
TabContainer1.Tabs.Add(tp);
html 部分是: part:blahblahblahblah
i am working on a project.but i have a problem.basically,i am using ajaxtoolkit tabcontainer.assume that i have 2 tabs which i created.let's call them tab1,tab2.in tab1 there is a button and textbox.when i click the button,i am writing some text into the textbox.then i am creating a tab dynamically.assume that it is called "tab3".the problem is when i click the button in the tab1,tab3 is diappearing.how can i prevent this?
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true"
Height="273px" Width="1050px">
<asp:TabPanel runat="server" HeaderText="tab1" ID="tab1">
<ContentTemplate>
tab2
here is where i am adding a new tab in the function:
AjaxControlToolkit.TabPanel tp = new AjaxControlToolkit.TabPanel();
tp.HeaderText = "tab3";
tp.ContentTemplate = Page.LoadTemplate("WebUserControl1.ascx");
tp.ID = "tab3";
TabContainer1.Tabs.Add(tp);
The html part is: part:blahblahblahblah
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
处理任何动态控件时,您需要在每次回发后重新添加它们。我的建议是将动态添加的控件存储在 ViewState 中,并编写一个从 ViewState 检索信息并添加选项卡的方法。然后从 Page_Init 调用此方法。
When dealing with any dynamic controls, you will need to re-add them after every postback. My recommendation is to store your dynamically-added controls in the ViewState, and write a method that retrieves the information from ViewState and adds your tabs. Then call this method from Page_Init.