From the course: Blazor: Getting Started

Unlock the full course today

Join today to access over 22,700 courses taught by industry experts or purchase this course individually.

Solution: RayInput validation

Solution: RayInput validation - Blazor Tutorial

From the course: Blazor: Getting Started

Start my 1-month free trial

Solution: RayInput validation

(upbeat music) - [Instructor] Are you ready for the solution? First, let's run and have a look at it. When I select a frequency, I can see this as a text area that I can expand or shrink. If I try to cast an empty Ray, I get a validation error. But I can still select a new frequency, see my name, and cast that Ray successfully. Let's look at the code I added to make this possible. We'll click to see the files. I'll start in the ViewModels folder in BeamClient. Here, I added a new model RayToCast. I made it required with the error message, "You can't send an empty Ray." In the RayInput, I added my new EditForm here, on line four, the DataAnnotationValidator on line five. I added the ValidationMessage on line 15 and changed the input to an InputTextArea here, on line seven. Down here in the code, I changed the Parameter to my new ViewModel and changed my references to that ViewModel's dot Text property in CastRay…

Contents