最簡單的方法是使用ScriptManager的PageMethod。
1個啓用pagemethods
<asp:ScriptManager runat="server" EnablePageMethods="true"></asp:ScriptManager>
2創建ASPX頁面內PageMethod的是會得到實際的標籤信息
[WebMethod]
public static void SaveCurrentTab(string controlId, int currentTabIndex)
{
// save data to session
}
3實際數據發送到服務器上創建JS-功能處理器
<script type="text/javascript">
function clientActiveTabChanged(sender, args) {
PageMethods.SaveCurrentTab(sender.get_id(), sender.get_activeTabIndex());
}
</script>
4將js-handler附加到TabContainer
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" OnClientActiveTabChanged="clientActiveTabChanged">
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="Test1">
<ContentTemplate>Test1</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel2" runat="server" HeaderText="Test2">
<ContentTemplate>Test2</ContentTemplate>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ID="TabPanel3" runat="server" HeaderText="Test3">
<ContentTemplate>Test3</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
PS在cookie的客戶端有另外的決策保存數據。
奇妙的是,這是一種享受!非常感謝 – Chris
歡迎:) – vladimir77