我在两个单独的 Jquery 选项卡面板上有两个 aspx 按钮。我想从后面的 c# 代码中获取活动 Jquery 选项卡的索引,以便该选项卡中的按钮变得不可见。任何帮助将不胜感激。ASP:
<asp:HiddenField ID="hiddenFGetActiveTab" runat="server"/>
<button ID="btnGetActiveTab"></button>
<div id="tabs">
<ul>
<li><a href="#tabs-1"></a></li>
<li><a href="#tabs-2"></a></li>
</ul>
<div id="tabs-1" style="border: 1px solid #E5E5E5;">
<asp:UpdatePanel ID="updatePanelSearchCustomer" runat="server" UpdateMode="Conditional">
<contentTemplate>
<asp:Button ID="btnCustSearch" runat="server" Text="Search" ToolTip="Click to Search" OnClick="btnCustSearch_Click" />
<asp:Button ID="btnAddCustomer" runat="server" Text="Add New" CommandName="insert" Visible="True" ToolTip="Add to Workbasket" OnClick="addToWorkBasket_Click" />
<asp:GridView ID="gridCustSearch" OnRowCreated="gridCustLicSearch_RowCreated runat="server"></asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div id="tabs-2" style="border: 1px solid #E5E5E5;">
<asp:Button ID="btnSearchLicense" runat="server" Text="Search" ToolTip="Click to Search" />
<asp:Button ID="btnAddLicense" runat="server" Text="Add to Workbasket" Visible="False" ToolTip="Add to Workbasket" OnClick="btnAddLicense_Click" />
<asp:UpdatePanel ID="updatePanelLicenseSearchFields" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gridLicSearch" runat="server" OnRowCreated="gridCustLicSearch_RowCreated"></asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
查询:
<link href="../css/jquery-ui-1.9.2.custom.css" rel="stylesheet" />
<script src="../js/jquery-1.8.3.js"></script>
<script src="../js/reflection.js"></script>
<script src="../js/jquery-ui-1.9.2.custom.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(function () {
$("#tabs").tabs({ event: "click" });
});
$('#btnGetActiveTab').click(function (event) {
event.preventDefault();
varTab = $("#tabs").tabs("option", "selected");
document.getElementById("<%= hiddenFGetActiveTab.ClientID %>").value = varTab;
//$("#hiddenFGetActiveTab").val(varTab);
//alert(varTab);
alert(document.getElementById("<%= hiddenFGetActiveTab.ClientID %>").value);
});
function tabChanged(tabIndex) {
varTab = $("#tabs").tabs("option", "selected");
$("#hiddenFGetActiveTab").val(varTab);
alert(document.getElementById("<%= hiddenFGetActiveTab.ClientID %>").value);
}
});
C#代码背后:
protected void gridCustLicSearch_RowCreated(object sender, GridViewRowEventArgs e)
if (activeTabIndex == Tab-1)
{
//Make First button visible
//do other stuff
}
else if (activeTab == Tab-2)
{
//Make Second button visible
//do other stuff
}