Set Focus to RadEditor with ASP RequiredFieldValidtor

2 posts, 0 answers
  1. Lee
    Lee avatar
    2 posts
    Member since:
    May 2009

    Posted 19 Feb Link to this post

    I am unable to set focus when a required field validator is fired for a RadEditor.

    I also have this issue to solve for a RadDatePicker and RadTimePicker.

    I found this http://www.telerik.com/forums/how-to-use-requiredfieldvalidator-to-setfocusonerror-with-radeditor but I have multiple RadEditors on the page only one o f which is a required field.

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3599 posts

    Posted 24 Feb Link to this post

    Hi Lee,

    The linked forum thread offers an example that you can use as base to focus the editor.

    Note that required field validators do not focus the control they validate, you can see this with the following basic snippet:

    <asp:TextBox ID="Textbox1" runat="server" />
    <asp:RequiredFieldValidator ID="Requiredfieldvalidator1" ErrorMessage="errormessage" ControlToValidate="Textbox1" runat="server" />
    <asp:Button ID="Button1" Text="text" runat="server" />

    Since this is a feature of the validator, not of the editor, I advise that you use the client-side click event of the button to validate the page manually and execute any desired logic in a fashion similar to one of the last posts of Sleete's: http://www.telerik.com/forums/how-to-use-requiredfieldvalidator-to-setfocusonerror-with-radeditor#5FcazoaT0EyQQ1eMepJcFg. You may also find interesting the following approach that lets you fire client-side validation and execute custom logic: http://docs.telerik.com/devtools/aspnet-ajax/controls/button/how-to/radbutton-validation-and-client-side-event-handlers (note the call to Page_ClientValidate(validationGroupName)). You can loop through the validators and focus the desired element with your own code then.

    Regards,

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