set focus after validation

2 posts, 0 answers
  1. Fit2Page
    Fit2Page avatar
    345 posts
    Member since:
    Feb 2007

    Posted 24 Aug 2015 Link to this post

    How could I set focus on the Radrating after client-side validation like:

     

    http://docs.telerik.com/devtools/aspnet-ajax/controls/rating/how-to/radrating-with-customvalidatorplease help.

     

    Marc

  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 27 Aug 2015 Link to this post

    Hi,

    If you want to focus RadRating when you use it in combination with a CustomValidator, for example if the validation fails, you can try the following approach:
    1. Set the TabIndex property of the rating control so that it can be focused:
      <telerik:RadRating ID="RadRating1" runat="server" TabIndex="1">
      </telerik:RadRating>
    2. Modify the body of the ValidateRating handler in order to include retrieving of the HTML element of the rating and focusing it. The following example shows how to do so when the validation fails:
      function ValidateRating(source, args) {
          args.IsValid = (args.Value > 0);
          if (!args.IsValid) {
              $find("<%=RadRating1.ClientID %>").get_element().focus();
          }
      }


    Regards,
    Slav
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top