ローカルの SQLite データベースから動的データを読み込んで表示する ASPX ページをセットアップしました。データは別の C# アプリケーションからデータベースに書き込まれるため、データベースがアクティブに新しいデータを受信しているとフラグを立てたときに ASPX ページを 30 秒ごとに更新するように設定しました。
私の ASPX ページには、それぞれがデータの異なるビューを表すいくつかの異なる TabPanels を持つ TabContainer があります。ここで、ページが更新されると、アクティブなタブ パネルが ASPX ページで ActiveTabIndex として設定されたものにリセットされます。
どのタブが記憶されているかを保持する簡単な方法があるかどうか疑問に思っていました。
ありがとう!
コードサンプルを追加するために編集
MyPage.aspx
<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPageFile.master" AutoEventWireup="true" CodeFile="MyPage.aspx.cs" Inherits="MyPage" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" Runat="Server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager" runat="server" />
<asp:TabContainer ID="tabContainer" runat="server" ActiveTabIndex="1" CssClass="myTabStyle" Visible="true">
<asp:TabPanel ID="tab1" runat="server" HeaderText="Tab 1">
<ContentTemplate>
<p>Hello</p>
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="tab2" runat="server" HeaderText="Tab 2">
<ContentTemplate>
<asp:PlaceHolder ID="tab2placeholder" runat="server" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="tab3" runat="server" HeaderText="Tab 3">
<ContentTemplate>
<asp:TabContainer ID="tab3content" runat="server" ActiveTabIndex="0" CssClass="myTabeStyle" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel ID="tab4" runat="server" HeaderText="Tab 4">
<ContentTemplate>
<p>Blah.</p>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
</asp:Content>
MyPage.aspx.cs
public partial class MyPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
...
if (isInProgress)
{
Response.AddHeader("Refresh", "30");
}
LoadTab1();
LoadTab2();
LoadTab3();
LoadTab4();
...
}
}