需要基于会话变量启用或禁用RadTabStrip中的选项卡
本文关键字:RadTabStrip 选项 启用 变量 于会话 会话 | 更新日期: 2023-09-27 17:50:29
我正在使用Telerik Rad控件,我试图找出正确的方法来使用,当我需要启用或禁用基于会话变量的RadTabStrip中的选项卡时。您可能会想到RadTabStrip.Mytab.enabled = false
之类的东西,但您不能为选项卡分配单独的id。我已经通读了文档,但我似乎不知道如何基于会话来做。
感谢您的帮助。
// If the user is still in a session - Enable a certain Tab in the TabStrip and a certain PageView based on the current session variable.
if (Session["PaymentStep"] != null)
{
switch (Session["PaymentStep"].ToString())
{
case "1":
// Need to select the "Bill" tab somehow and disable the rest
BillPayRadMultiPage.SelectedIndex = 0;
break;
case "2":
// Need to select the "Provider" tab somehow and disable the rest
BillPayRadMultiPage.SelectedIndex = 2;
break;
case "3":
// Need to select the "Payment" tab somehow and disable the rest
BillPayRadMultiPage.SelectedIndex = 3;
break;
case "4":
// Need to select the "Confirmation" tab somehow and disable the rest
BillPayRadMultiPage.SelectedIndex = 4;
break;
case "5":
// Need to select the "Reciept" tab somehow and disable the rest
BillPayRadMultiPage.SelectedIndex = 5;
break;
default:
break;
}
}
这是我目前在我的页面上的内容
<!-- TabStrip -->
<div class="BillPayWrapper">
<telerik:RadTabStrip ID="BillPayNavigationRadTabStrip" SelectedIndex="0" runat="server" MultiPageID="BillPayRadMultiPage" Align="Justify"
Skin="Silk" CssClass="tabStrip" CausesValidation="false">
<Tabs>
<telerik:RadTab runat="server" Text="Bill" PageViewID="Step1View"
ImageUrl="Images/1_normal.png"
SelectedImageUrl="Images/1_active.png" />
<telerik:RadTab runat="server" Text="Provider" PageViewID="Step2View"
ImageUrl="Images/2_normal.png"
SelectedImageUrl="Images/2_active.png"
DisabledImageUrl="Images/2_disable.png" />
<telerik:RadTab runat="server" Text="Payment" PageViewID="Step3View"
ImageUrl="Images/3_normal.png"
SelectedImageUrl="Images/3_active.png"
DisabledImageUrl="Images/3_disable.png" />
<telerik:RadTab runat="server" Text="Confirmation" PageViewID="Step4View"
ImageUrl="Images/4_normal.png"
SelectedImageUrl="Images/4_active.png"
DisabledImageUrl="Images/4_disable.png" />
<telerik:RadTab runat="server" Text="Reciept" PageViewID="Step5View"
ImageUrl="Images/5_normal.png"
SelectedImageUrl="Images/5_active.png"
DisabledImageUrl="Images/5_disable.png" />
</Tabs>
</telerik:RadTabStrip>
<!-- MultiPage Container -->
<telerik:RadMultiPage ID="BillPayRadMultiPage" runat="server" SelectedIndex="0"
CssClass="multiPage" BorderWidth="1" BorderColor="#888888">
<!-- Step 1 PageView -->
<telerik:RadPageView ID="Step1RadPageView" runat="server">
<h1>Step 1 Content</h1>
</telerik:RadPageView>
<!-- // Step 1 PageView -->
<!-- Step 2 PageView -->
<telerik:RadPageView ID="Step2RadPageView" runat="server">
<h1>Step 2 Content</h1>
</telerik:RadPageView>
<!-- // Step 2 PageView -->
<!-- You get the idea -->
</telerik:RadMultiPage>
大家别介意,
我似乎已经弄明白了。我可以通过使用标签的索引来启用或禁用标签。我找到了正确的语法,并将其应用于会话检查循环。 case "1":
BillPayNavigationRadTabStrip.Tabs[0].Enabled = true;
BillPayNavigationRadTabStrip.Tabs[0].Selected = true;
BillPayNavigationRadTabStrip.Tabs[1].Enabled = false;
BillPayNavigationRadTabStrip.Tabs[2].Enabled = false;
BillPayNavigationRadTabStrip.Tabs[3].Enabled = false;
BillPayNavigationRadTabStrip.Tabs[4].Enabled = false;
BillPayRadMultiPage.SelectedIndex = 0;
break;