Custom Advanced Form with required Resources

Thread is closed for posting
1 posts, 0 answers
  1. E2DE6E82-E2D9-4F0D-906D-3F1E2C32B9D6
    E2DE6E82-E2D9-4F0D-906D-3F1E2C32B9D6 avatar
    12 posts
    Member since:
    Jan 2017

    Posted 10 Aug 2017 Link to this post


    Telerik Product and Version

    UI for ASP.NET AJAX 2017 R3

    Supported Browsers and Platforms

    all browsers supported by Telerik UI for ASP.NET AJAX suite

    Components/Widgets used (JS frameworks, etc.)

    RadScheduler, RadComboBox, .NET 4.0/4.5 C#

    This example demonstrates how to make the Room resource required in the Custom Advanced form.

    Generally, the validation for the resources ComboBox is not fired when saving the form because the ComboBox validation group is not the same as the one of the Save button. The validators for the subject and dates have their ValidationGroup properties set in the InitializeStrings() method of the AdvancedFormCS.ascx.cs/AdvancedFormVB.ascx.vb file. 

    One option to overcome this issue is setting the ValidationGroup property in the InitializeStrings() method as follows:

    AdvancedFormCS.ascx/AdvancedFormVB.ascx file:

    <li class="rfbRow">
        <!-- Resource controls should follow the convention Res[Resource Name] for ID -->
        <scheduler:ResourceControl runat="server" ID="ResRoom" Type="Room" Label="Room" />
      <asp:RequiredFieldValidator runat="server" ID="ResourceValidator" ControlToValidate="ResRoom$ResourceValue" InitialValue="-"
            EnableClientScript="true" Display="None" CssClass="rsValidatorMsg" />


    asp:Label runat="server" ID="ResourceLabel" AssociatedControlID="ResourceValue" Text='<%# Label %>' CssClass="rfbLabel" />
    <telerik:RadComboBox runat="server" ID="ResourceValue" CssClass="rsAdvResourceValue" Skin='<%# Skin %>' RenderMode="Lightweight" />

    AdvancedFormCS.ascx.cs file:

    private void InitializeStrings()
        ResourceValidator.ErrorMessage = "Choose a resource";
        ResourceValidator.ValidationGroup = Owner.ValidationGroup;
        // other validators here

    AdvancedFormVB.ascx.vb file:

    Private Sub InitializeStrings()
        ResourceValidator.ErrorMessage = "Choose a resource"
        ResourceValidator.ValidationGroup = Owner.ValidationGroup
        ' other validators here
    End Sub

    Another option is setting it directly in the markup:

    <asp:RequiredFieldValidator runat="server" ID="ResourceValidator" ControlToValidate="ResRoom$ResourceValue" InitialValue="-" EnableClientScript="true" Display="None" ValidationGroup='<%# Owner.ValidationGroup %>' CssClass="rsValidatorMsg" />

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.