简体   繁体   English

如何强制填写radtabstrip的前2个标签?

[英]How to make first 2 tabs of radtabstrip mandatory to be filled out?

I have an ASP.NET project with telerik embedded. 我有一个嵌入了telerik的ASP.NET项目。 The telerik control I have is RadTabStrip. 我拥有的telerik控件是RadTabStrip。 The current task is The customer wants the first 2 tabs "Employee" and "general info" to be fill out first before they are able to fill out the other tabs. 当前的任务是:客户希望先填写前两个选项卡“雇员”和“常规信息”,然后才能填写其他选项卡。

Not sure how to implement this. 不确定如何实施。 Here is a sample 这是一个样本

<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">

Here is the tab code. 这是标签代码。

<!-- 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>

And another 还有一个

<!-- 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" />&nbsp;<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>

It is very difficult to give you a solution based on your own code because of all the custom references. 由于所有自定义引用,很难为您提供基于自己的代码的解决方案。 However, the controls in the various tabs can be accessed directly from code behind. 但是,可以从后面的代码直接访问各个选项卡中的控件。 I made a test on a 3 tabs RadTabStrip playing on enabling tab2. 我在启用tab2的3个RadTabStrip选项卡上进行了测试。

UPDATE UPDATE

Something went wrong with the previous example. 前面的示例出了点问题。 I had to use some Javascript to resolve the issue on the client side. 我必须使用一些Javascript来解决客户端的问题。 I tested this code and it is working. 我测试了此代码,它正在工作。 Basically there are two textboxes on the first tab and a button that is disabled by default. 基本上,第一个选项卡上有两个文本框,并且默认情况下禁用了一个按钮。 The button gets enabled only if text is in both textboxes (I understood you have more than one control on the tab that needs to be filled-in so this is a good example). 仅当两个文本框中均包含文本时,该按钮才会启用(我知道您在选项卡上有多个控件需要填写,因此这是一个很好的示例)。 Then clicking the button you enable tab 2. You can rewrite the javascript to enable directly the tabs when your fields/controls on the first and second tab are satisfying the requirements. 然后单击按钮启用选项卡2。当第一个和第二个选项卡上的字段/控件满足要求时,可以重写javascript以直接启用选项卡。

In PAGE_LOAD set the tabs that should not be visible or enabled 在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;
    }

Here is the rest of the code with the script 这是脚本的其余代码

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何使两个字段成为必需字段(数据验证),并且在消息中显示两个字段都应填写? - How do i make it possible to make two fields mandatory(data validation) and in the message show that both should be filled? 需要基于会话变量启用或禁用RadTabStrip中的选项卡 - Need to enable or disable tabs in RadTabStrip based on a session variable 如何在XML模式中使这两个字段成为强制性 - How to make either of the fields mandatory in XML schema 如何让第二个签名者依赖于第一个签名者的选择? 条件选项卡和签名者 - How to make a second signer dependant on the first one's choice? Conditional tabs and signers 如何在C#中制作部分填充的数组 - How to make a Partially Filled Array in C# 强制下拉列表继续 - Make dropdownlist mandatory for continuing 仅当项目列表不为空时如何强制选择 DropDownList - How to make DropDownList selection mandatory only if item list is not empty 如何在 Windows Installer 自定义对话框中将字段设为必填项 - How to make a field Mandatory in Windows Installer custom dialog 如何在asp.net core 2.1中不强制登录或注册? - How to not make login or register mandatory in asp.net core 2.1? 如何判断一个memory stream是否填妥 - How to find out whether a memory stream is filled properly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM