繁体   English   中英

html表在ajaxToolkit:TabPanel中时消失

[英]html table disappears when it is inside ajaxToolkit:TabPanel

我使用tablesorter插件对HTML TABLE进行了排序。 当我将表格放在ajaxToolkit TabPanel中时,HTML表格的标题就会消失。 (当HTML表在ajaxToolkit TabPanel外部时,可以)

    $(window).load(function () {  
        $('#ConnectedActivitiesTable').append("<thead> <tr> <th> profix </th> <th> prog </th> <th> loc </th> <th> pop </th> <th> div </th> </tr> </thead>");
        $("#ConnectedActivitiesTable").tablesorter();
    });

   <ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxToolkit:ToolkitScriptManager>
    <ajaxToolkit:TabContainer ID="TabContainer1" ActiveTabIndex="0" Width="100%"  height="300px" runat="server">
        <ajaxToolkit:TabPanel ID="AboutTab" HeaderText="about" runat="server">
            <ContentTemplate>
                <table id="TabsContainer" class="tabsContainer">

                </table>
            </ContentTemplate>
        </ajaxToolkit:TabPanel>

        <ajaxToolkit:TabPanel ID="RelatedPrograms" HeaderText="connected" runat="server">
            <ContentTemplate>
                   <table id="ConnectedActivitiesTable" runat="server" class=tbl > </table>
            </ContentTemplate>
        </ajaxToolkit:TabPanel>

问题在于ConnectedActivitiesTable ConnectedActivitiesTable填充在C#代码背后

    public static void ShowTable(List<ActivityAllDetails> activityList, HtmlTable htmlTable)
    {
        htmlTable.Visible = true;
        HtmlTableCell cell;
        HtmlTableRow row;

        foreach (var activity in activityList)
        {
            cell = new HtmlTableCell();
            cell.Attributes.Add("dir", "ltr");
            cell.InnerText = activity.ProphixNo;
            row = new HtmlTableRow();
            row.Controls.Add(cell);

            cell = new HtmlTableCell();

            cell.InnerHtml = "<a href=Tabs.aspx?" + QryStringKeys.ACTIVITY_ID + "=" + activity.ActivityId + ">" + (activity.Prg2NameHeb != null ? activity.Prg2NameHeb : activity.Prg2Name) + " </a>";
            row.Controls.Add(cell);

            cell = new HtmlTableCell();
            cell.InnerText = activity.LocationDesc;
            row.Controls.Add(cell);


            cell = new HtmlTableCell();
            cell.InnerText = activity.PopulationDesc;
            row.Controls.Add(cell);

            cell = new HtmlTableCell();
            cell.InnerText = activity.DivisionDesc;
            row.Controls.Add(cell);


            htmlTable.Controls.Add(row);
        } 

    }

谢谢

我找到了答案。

将HTML表放在ajaxToolkit:TabPanel中时,Ajax会更改HTML表的ID(在源代码中可见)。 因此,HTML表必须由新ID或使用用于引用的类来引用。

<table id="ConnectedActivitiesTable" runat="server"  class="ConnectedActivitiesTableCss">

<script type="text/javascript">
 $(window).load(function () { 
            $('.ConnectedActivitiesTableCss').append("<thead> <tr> <th> profix </th> <th> prg </th> <th> loc</th> <th> pop</th> <th> div</th> </tr> </thead>");            
       });
</script>

我将iD-specifier $('#ConnectedActivitiesTable')更改为class-specifier $('.ConnectedActivitiesTableCss')

暂无
暂无

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

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