我有一个嵌入了telerik的ASP.NET项目。 我的telerik控件是RadTabStrip。 当前的任务是客户需要前两个标签"员工"和"一般信息"在他们能够填写其他标签之前先填写。
不确定如何实现这一点。这是一个样本
<telerik:RadTabStrip ID="RadTabStrip1" runat="server" SelectedIndex="0" MultiPageID="RadMultiPage1"
Skin="Telerik" CausesValidation="false">
<Tabs>
<telerik:RadTab runat="server" Selected="True">
<TabTemplate>
<asp:Label ID="Label29" runat="server" Text="<%$ Resources:strings, sample_generalinformation %>" />
<img id="generalInfoErrorIndicator" src="../Images/alert-small.gif" alt="" style="display: none;" />
</TabTemplate>
</telerik:RadTab>
<telerik:RadTab runat="server">
这是标签代码。
<!-- EMPLOYEE INFORMATION -->
<telerik:RadPageView ID="pvEmployeeInformation" runat="server">
<div id="employeeInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="2">
<h1>
<asp:Label ID="Label34" runat="server" Text="<%$ Resources:strings, observed_employee_information %>" /></h1>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label12" runat="server" Text="<%$ Resources:strings, employee_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:EmployeeSearch ID="employeeSearch" runat="server" OnClientEmployeeSelected="employeeSelected"
ClientValidationFunction="validateEmployee" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td>
<asp:CheckBox ID="areaSampleCheckBox" runat="server" Text="<%$ Resources:strings, labels_areasample %>"
ValidationGroup="employeeInfo" />
</td>
<td>
<asp:CheckBox ID="unknownEmployeeCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownemployee %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label13" runat="server" Text="<%$ Resources:strings, job_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:JobSearch ID="jobSearch" runat="server" ValidationGroup="employeeInfo" ClientValidationFunction="validateJob"
OnClientJobSelected="jobSelected" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:CheckBox ID="unknownJobCheckBox" runat="server" Text="<%$ Resources:strings, labels_unknownjob %>" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label14" runat="server" Text="<%$ Resources:strings, shift_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftDropDown ID="shiftDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td style="text-align: right;">
<asp:Label ID="Label15" runat="server" Text="<%$ Resources:strings, shiftlength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewShiftLengthDropDown ID="shiftLengthDropDown" runat="server" ValidationGroup="employeeInfo" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:ValidationSummary ID="employeeInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="employeeInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
另一个
<!-- GENERAL INFORMATION -->
<telerik:RadPageView ID="pvGeneralInformation" runat="server">
<div id="generalInfoDiv" runat="server">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td colspan="4">
<h1>
<asp:Label ID="Label16" runat="server" Text="<%$ Resources:strings, general_information %>" /></h1>
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label1" runat="server" Text="<%$ Resources:strings, facility_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:FacilitySearch ID="facilitySearch" runat="server" ValidationGroup="generalInfo"
OnClientFacilitySelected="facilitySelected" OnClientFacilityCleared="facilityCleared"
AutoPostBack="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label7" runat="server" Text="<%$ Resources:strings, samplelength_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleLengthDropDown ID="sampleLengthDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;">
<asp:Label ID="Label2" runat="server" Text="<%$ Resources:strings, sampledate_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewDateEntry ID="sampleDate" runat="server" ValidationGroup="generalInfo"
ValidateDateNotInFuture="true" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label8" runat="server" Text="<%$ Resources:strings, samplemethod_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:SampleMethodSearch ID="sampleMethodSearch" runat="server" ValidationGroup="generalInfo"
OnClientSampleMethodSelected="sampleMethodSelected" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right;">
<asp:Label ID="Label3" runat="server" Text="<%$ Resources:strings, sampletype_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleTypeDropDown ID="sampleTypeDropDown" runat="server" ValidationGroup="generalInfo"
FormDesignator="PassiveBadge" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label69" runat="server" Text="<%$ Resources:strings, samplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="sampleNumberTextBox" runat="server" Skin="Telerik" Width="200px" /> <asp:Image
ID="sampleNumberInfoImage" runat="server" ImageUrl="~/Images/info.png" ToolTip="<%$ Resources:strings, samplenumber_info %>" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator19" runat="server"
ControlToValidate="sampleNumberTextBox" ErrorMessage="<%$ Resources:strings, validations_fieldlength_16 %>"
ToolTip="<%$ Resources:strings, validations_fieldlength_16 %>" ValidationExpression="<%$ AppSettings:Length16ValidationExpression %>"
ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label4" runat="server" Text="<%$ Resources:strings, occupationalhealthlimit_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:OelSearch ID="oelSearch" runat="server" ValidationGroup="generalInfo" OnClientOelSelected="oelSelected" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label10" runat="server" Text="<%$ Resources:strings, labsamplenumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="labSampleNumberTextBox" runat="server" Skin="Telerik" Width="175px" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="labSampleNumberTextBox"
ErrorMessage="<%$ Resources:strings, labsamplenumber_length %>" ToolTip="<%$ Resources:strings, labsamplenumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label67" runat="server" Text="<%$ Resources:strings, exposuregroup_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:ExposureGroupSearch ID="exposureGroupSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td colspan="2" align="center">
<table border="0" cellpadding="3" cellspacing="2">
<tr>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label11" runat="server" Text="<%$ Resources:strings, stelsample_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="stelSampleCheckBox" runat="server" />
</td>
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label68" runat="server" Text="<%$ Resources:strings, labels_ceiling %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<asp:CheckBox ID="ceilingSampleCheckBox" runat="server" />
</td>
</tr>
</table>
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label5" runat="server" Text="<%$ Resources:strings, collectinguser_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:AdminUserSearch ID="adminUserSearch" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label18" runat="server" Text="<%$ Resources:strings, samplingdevice_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSamplingDeviceDropDown ID="samplingDeviceDropDown" runat="server" />
</td>
</tr>
<tr valign="top">
<td style="text-align: right; padding-left: 10px;" valign="top">
<asp:Label ID="Label6" runat="server" Text="<%$ Resources:strings, samplestrategy_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<ihamm:NewSampleStrategyDropDown ID="sampleStrategyDropDown" runat="server" ValidationGroup="generalInfo" />
</td>
<td style="text-align: right;">
<asp:Label ID="Label19" runat="server" Text="<%$ Resources:strings, blanknumber_label %>"
Font-Bold="True" ForeColor="Navy" />
</td>
<td style="text-align: left;">
<telerik:RadTextBox ID="blankNumberTextBox" runat="server" Skin="Telerik" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_required %>" ToolTip="<%$ Resources:strings, blanknumber_required %>"
ValidationGroup="generalInfo" />
<asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="blankNumberTextBox"
ErrorMessage="<%$ Resources:strings, blanknumber_length %>" ToolTip="<%$ Resources:strings, blanknumber_length %>"
ValidationExpression="<%$ AppSettings:Length64ValidationExpression %>" ValidationGroup="generalInfo" />
</td>
</tr>
<tr valign="top">
<td colspan="4">
<asp:ValidationSummary ID="generalInformationValidationSummary" runat="server" Font-Bold="True"
ForeColor="Red" HeaderText="<%$ Resources:strings, validationsummary_nextwizard_msg %>"
ValidationGroup="generalInfo" />
</td>
</tr>
</table>
</div>
</telerik:RadPageView>
答案 0 :(得分:0)
由于所有自定义引用,很难根据您自己的代码为您提供解决方案。但是,可以直接从后面的代码访问各个选项卡中的控件。我在启用tab2的3个选项卡RadTabStrip上进行了测试。
<强>更新强>
上一个例子出了点问题。我不得不使用一些Javascript来解决客户端问题。我测试了这段代码,它正在运行。基本上,第一个选项卡上有两个文本框,默认情况下禁用一个按钮。只有文本在两个文本框中时才会启用该按钮(我知道您需要填充的选项卡上有多个控件,所以这是一个很好的例子)。然后单击启用选项卡2的按钮。当第一个和第二个选项卡上的字段/控件满足要求时,您可以重写javascript以直接启用选项卡。
在PAGE_LOAD中设置不应显示或启用的选项卡
protected void Page_Load(object sender, EventArgs e)
{
//RadTabStrip1.Tabs[2].Visible = false;
RadTabStrip1.Tabs[2].Enabled = false;
}
protected void Button1_Click(object sender, EventArgs e)
{
RadTabStrip1.Tabs[2].Enabled = true;
}
以下是脚本
的其余代码<body>
<form id="form1" runat="server">
<script language="javascript" type="text/javascript">
//function to enable button if two textboxes contains text
function SetButtonStatus(sender, target) {
var first = document.getElementById('<%=TextBox1.ClientID %>');
var second = document.getElementById('<%=TextBox2.ClientID %>');
//Condition to check whether user enters text in two textboxes or not
if ((sender.value.length >= 1 && first.value.length >= 1) && (sender.value.length >= 1 && second.value.length >= 1))
document.getElementById(target).disabled = false;
else
document.getElementById(target).disabled = true;
}
</script>
<telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
<div>
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" MultiPageID="RadMultiPage1" SelectedIndex="0" Skin="Silk">
<Tabs>
<telerik:RadTab Text="I am Tab 0" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 1" Width="200px"></telerik:RadTab>
<telerik:RadTab Text="I am Tab 2" Width="200px"></telerik:RadTab>
</Tabs>
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0" CssClass="outerMultiPage">
<telerik:RadPageView runat="server" ID="RadPageView1">
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip2" MultiPageID="RadMultiPage2"
Orientation="VerticalLeft" Skin="Silk" Width="50px" Height="355px" SelectedIndex="0">
</telerik:RadTabStrip>
<telerik:RadMultiPage runat="server" ID="RadMultiPage2" SelectedIndex="0" CssClass="innerMultiPage">
<telerik:RadPageView runat="server" ID="PageView1">
<div>
<asp:TextBox ID="TextBox1" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" onkeyup="SetButtonStatus(this,'btnButton')"></asp:TextBox>
<asp:Button ID="btnButton" runat="server" Text="Button" Enabled="false" OnClick="Button1_Click" />
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView2">
<div></div>
<div>
<p>Something</p>
</div>
</telerik:RadPageView>
<telerik:RadPageView runat="server" ID="RadPageView3">
<div>
<p>Again something</p>
</div>
</telerik:RadPageView>
</telerik:RadMultiPage>
</div>
</form>
</body>