This is a migrated thread and some comments may be shown as answers.

Set Focus to RadEditor with ASP RequiredFieldValidtor

1 Answer 99 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 19 Feb 2016, 12:50 PM

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.

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 24 Feb 2016, 07:58 AM

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
Tags
Editor
Asked by
Lee
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or