New to Telerik UI for ASP.NET MVC? Start a free 30-day trial
Displaying a Validation Summary in a Dialog
Environment
Product | Telerik UI for ASP.NET MVC Dialog |
Progress Telerik UI for ASP.NET MVC version | Created with the 2022.2.621 version |
Description
How can I show a validation summary in the Telerik UI for ASP.NET MVC Dialog?
Solution
- Set an initial HTML content within the Dialog which will act as a container for the error messages.
- Get the reference of the validator and attach a handler to the
validate
event through the.bind()
configuration method. - Within the handler, assess if any errors have occurred by using the
.errors()
method. Based on the evaluation, append the error messages to the content of the Dialog and open it.
Index.cshtml
<form id="myform">
<input name="username" required /> <br />
<input name="password" required /> <br />
<button>Validate</button>
</form>
@(Html.Kendo().Dialog()
.Name("SMEValidationSummary")
.Title("SME Validation Summary")
.Closable(false)
.Content("<div class='errors'></div>")
.Width(400)
.Modal(true)
.Visible(false)
.Actions(actions =>
{
actions.Add().Text("OK").Primary(true);
})
)
For the complete implementation of the suggested approach, refer to the following Telerik REPL example.