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 - Blazor Tutorial
From the course: Blazor: Getting Started
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Debugging with Blazor7m 9s
-
(Locked)
Unit testing with Blazor8m 48s
-
(Locked)
Application changes for unit testing12m 4s
-
(Locked)
Unit testing components with parameters and services10m 4s
-
(Locked)
Forms and validation with Blazor10m 8s
-
(Locked)
Challenge: RayInput validation55s
-
(Locked)
Solution: RayInput validation3m 4s
-
-
-
-
-