I have a page with multiple CustomValidators and I want the focus to be brought to the offending validator when there is an error. I know this is possible with client side validation, but is it possible with server side?
Additionally, the CustomValidators are located in different parts of the page so I can’t simply scroll the page to one general location when there is any validation failure.
I have tried:
SetFocusOnError
CustomValidator.Focus() immediately after validation, after the button click, and in Page.PreRender()
Thanks in advance
Thanks to a colleague, I have a solution to this question. It’s so simple I wish I had come up with it! Just inject javascript when the validator fails and that javascript will be executed on postback.
where jumpToValidator(validatorId) is a javascript function that scrolls to the element passed in as an argument.