Validation

2 posts, 0 answers
  1. Allen
    Allen avatar
    21 posts
    Member since:
    Aug 2007

    Posted 06 May 2010 Link to this post

    I am trying to use a standard asp:RequiredFieldValidator with the control, but keep getting an error message "Control [rating] referenced by the ControlToValidate property of  [validator] cannot be validated."  I have other validators on the form that work fine.  Can this type of control not be validated this way?

    Thanks.
  2. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 10 May 2010 Link to this post

    Hi Allen,
    Yes, you are correct - currently the rating control cannot be validated with a RequiredFieldValidator control. You can use a CustomValidator control instead. For example:
    <script type="text/javascript">
        function ClientValidate(source,arguments)
        {
            var ratingValue = $find("<%= RadRating1.ClientID %>").get_value();
            if (ratingValue == 0)
            {
                arguments.IsValid = false;
            } else
            {
                arguments.IsValid = true;
            }
        }
     
    </script>
    <telerik:RadRating ID="RadRating1" runat="server">
    </telerik:RadRating>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidate"
        Display="Static" ErrorMessage="Please rate!"></asp:CustomValidator>
    <asp:Button ID="Button1" runat="server" Text="Postback" />

    Sincerely yours,
    Tsvetie
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top