(Edited- pivoted back to using [Remote] validation, but need to figure out how to keep popup in place after ModelState validation failure if user clicks submit)
Hi all,
I am working on a PopUp Editor for a Grid widget that displays user account information. The PopUp Editor is a custom template, and has Telerik TextBox widgets for the user account's data, including UserName. We want to validate the UserName by making a clientside call to the server to see if the UserName is already in use.
I am using [Remote] validation in our view model that makes a call from the clientside to a method in our controller that checks if the UserName is already in use. As has been the case with other people, this call is made even if a user clicks through the UserName Textbox and doesn't change the value for UserName, but our use case is such that I can work around this issue.
The problem is that if a user changes the username to an existing username, the Remote validation fires, but does not prevent the user from clicking Update on the PopUp- the user can click Update. On the server side, the Update will fail due to ModelState.IsValid = false, and a failure message is returned, but the user is not notified of the failure- the PopUp just fades out. If the user clicks "Edit" again, the username has the updated value in the PopUp, even though the update failed.
I was expecting that if the user clicks Submit, then the failure message that's returned would be displayed, and the PopUp would not fade out. I suspect it may have to do with using an custom Editor Template, but I'm hoping somebody can point out whatever it is I might be missing.
I used the following as guides:
- https://demos.telerik.com/aspnet-mvc/grid/editing-remote-validation
- https://www.telerik.com/forums/remote-validation-of-fields-in-grid-popup
- https://docs.telerik.com/aspnet-core/html-helpers/data-management/grid/editing/popup#handling-modelstate-errors
Has anybody been successful in using a custom template for PopUpEditor on a Grid, with a [Remote] validation, with the returned ModelState errors preventing the PopUpEditor from disappearing, instead displaying the returned error(s)?
Thanks in advance!
Taylor