validate radrating

2 posts, 0 answers
  1. Sigma
    Sigma avatar
    87 posts
    Member since:
    Apr 2012

    Posted 26 Nov 2012 Link to this post

    I have a radrating in my form. I want to validate whether the rating is checked using a customvalidator. Please help me to achieve this scenario.
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 26 Nov 2012 Link to this post

    Hi Sigma,

    Try the following code snippet to achieve your scenario.

    ASPX:
    <telerik:RadRating ID="RadRating1" runat="server">
    </telerik:RadRating>
    <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please rate"
        ControlToValidate="RadRating1" OnServerValidate="CustomValidator1_ServerValidate"
        ForeColor="Red">
    </asp:CustomValidator>
    <br />
    <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton">
    </telerik:RadButton>

    C#:
    protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
    {
        args.IsValid = (Int32.Parse(args.Value) > 0);
    }

    Please take a look into this documentation for more information.

    Regards,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top