简体   繁体   English

TabContainer问题

[英]TabContainer Problems

Having a strange issue with the TabContainer in the AJAX Toolkit. AJAX工具包中的TabContainer有一个奇怪的问题。

We have several views into a customer record system that we have built as ASP.net controls. 我们对作为ASP.net控件构建的客户记录系统有几个视图。 These controls use UpdatePanels to load data asynchronously. 这些控件使用UpdatePanels异步加载数据。 We use jQuery and jquery.ui to place these controls in separate tabs on a single page. 我们使用jQuery和jquery.ui将这些控件放在单个页面上的单独选项卡中。

Which all works swimmingly. 这一切都畅通无阻。

Lately, I've gotten a little tired of the jQuery tab hackish approach and decided to port everything to use the TabContainer. 最近,我对jQuery tab hackish的方法有些厌倦,决定移植所有内容以使用TabContainer。 I want to be able to control the tabs as objects. 我希望能够将选项卡作为对象进行控制。

At first glance, everything works perfectly. 乍一看,一切正常。 I just slapped the controls into tabs in a TabContainer and everything looked great. 我只是将控件拍到TabContainer的选项卡中,一切看起来都很棒。 However, for some reason, databound controls are losing their data. 但是,由于某种原因,数据绑定控件将丢失其数据。

For instance, grid views vanish when I switch pages. 例如,当我切换页面时,网格视图消失了。 A drop down control with an OnTextChanged event, loses its databound list of values upon post back. 带有OnTextChanged事件的下拉控件在回发时会丢失其数据绑定的值列表。

Something about the TabContainer -> Custom Control -> UpdatePanel -> Control that uses data binding heirarchy is throwing it out of whack and the debugger isn't shedding any light. TabContainer->自定义控件-> UpdatePanel->使用数据绑定层次结构的控件使它摆脱了束手无策的状态,并且调试器没有发挥任何作用。 It seems like control state isn't being stored. 似乎未存储控件状态。

I don't really know enough about control state to know what to look for. 我对控制状态的了解不多,不知道要查找什么。

Any ideas? 有任何想法吗? Here is the markup for the TabContainer: 这是TabContainer的标记:

<asp:TabContainer ID="tcBanner" runat="server" ActiveTabIndex="0" Width="100%" 
    EnableViewState="False" ScrollBars="Vertical">
    <asp:TabPanel runat="server" HeaderText="Comments" ID="tbComments">
        <ContentTemplate>
            <luBannerControl:Comments ID="commentsTabContent" runat="server" />
        </ContentTemplate>
    </asp:TabPanel>        
    <asp:TabPanel runat="server" HeaderText="General" ID="tbContact">
        <ContentTemplate>
            <luBannerControl:Contact ID="contactTabContent" runat="server" />
        </ContentTemplate>
    </asp:TabPanel>
</asp:TabContainer>

Here is the markup for one of the controls: 这是其中一个控件的标记:

<asp:UpdatePanel ID="pnlComments" UpdateMode="Conditional" runat="server">
    <ContentTemplate>
        <asp:GridView ID="CommentsGridView" AllowPaging="true" PageSize="20" DataSourceID="BannerSqlDataSource" runat="server" AutoGenerateColumns="False" GridLines="None" CssClass="CommentGrid" HeaderStyle-CssClass="CommentGridHeader" RowStyle-CssClass="CommentRowsEven" AlternatingRowStyle-CssClass="CommentRowsOdd">
            <Columns>
                <asp:BoundField DataField="SPRCMNT_TEXT" HeaderText="Comment" SortExpression="SPRCMNT_TEXT" />
                <asp:BoundField DataField="SPRCMNT_DATE" HeaderText="Created" SortExpression="SPRCMNT_DATE" DataFormatString="{0:M/dd/yyyy}" />
                <asp:BoundField DataField="SPRCMNT_CMTT_CODE" HeaderText="Type" SortExpression="SPRCMNT_CMTT_CODE" />
                <asp:BoundField DataField="SPRCMNT_CTYP_CODE" HeaderText="Source" SortExpression="SPRCMNT_CTYP_CODE" />
                <asp:BoundField DataField="sprcmnt_user_id" HeaderText="User" SortExpression="sprcmnt_user_id" />
            </Columns>
        </asp:GridView>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="txtSearch" EventName="TextChanged" />
        <asp:AsyncPostBackTrigger ControlID="btnClearFilter" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>

Make sure your TabContainer's OnDemand Property is turned off. 确保您的TabContainer的OnDemand属性已关闭。 I know for a fact that this can cause your controls such as GridView to lose their data while retain their rows, especially if you dynamically generate your controls. 我知道一个事实,这可能会导致您的控件(例如GridView)在保留其行的同时丢失其数据,尤其是在动态生成控件的情况下。

Via Markup: 通过标记:

<asp:TabContainer ID="tcBanner" runat="server" ActiveTabIndex="0" Width="100%" 
    EnableViewState="False" ScrollBars="Vertical" OnDemand="false" >

Via code: 通过代码:

tcBanner.OnDemand = false;

This ended up being completely unrelated to nested TabContainers. 最终与嵌套的TabContainer完全无关。

I had unknowingly broken the controls in question before adding them to the TabContainer and surprisingly, this meant they did not function the way they used to. 在将控件添加到TabContainer之前,我在不知不觉中破坏了这些控件,令人惊讶的是,这意味着它们无法像以前那样起作用。

Sorry for wasting your collective time. 很抱歉浪费您的集体时间。

Thanks, Clif 谢谢,克利夫

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM