(#50) Model validations in asp.net core | Asp.Net Core tutorial
ฝัง
- เผยแพร่เมื่อ 12 พ.ย. 2024
- Asp.net core tutorial: In this video, we will learn how to add model validations in asp.net core. We will implement server-side validations in asp.net core MVC applications using the System.ComponentModel.DataAnnotations namespace. We will learn what are validations and how to implement them on asp.net core form. We will also learn how to display the error message on the form.
Timestamp:
00:24 Agenda of this video
00:57 What is validation
02:42 What are the types of validations
05:00 Server-side validations in asp.net core
06:08 All validation attributes available in asp.net core
07:06 How to check model validation on a controller
07:34 What is the need of validations
09:12 What is the namespace for model validations
09:25 How to use Required attribute
10:00 ModelState.IsValid
12:33 Display error message on asp.net core form
13:51 Change color of error message
15:00 Custom error message in model validation
16:55 How to use StringLength validation attribute
#ModelValidations #WebGentle #Nitish
Join this channel to get access to perks:
/ @webgentle
GitHub Repo: github.com/web...
Subscribe WebGentle: goo.gl/PJr1pN
Visit Our Website: webgentle.com
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
For business inquiry contact: nitish.webgentle@gmail.com
Follow us on
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Facebook - bit.ly/36yZuQN
Linkedin - bit.ly/2N6Onqk
Twitter - bit.ly/2uv04AP
Popular free courses from WebGentle
▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
Jira tutorial - bit.ly/jiratuto...
Asp.Net Core Tutorial: bit.ly/aspnetco...
Azure DevOps tutorial - bit.ly/azuredev...
.NET Core 3.0 fundamentals - bit.ly/dotnetcore3
MVC5 tutorial - bit.ly/mvcbynitish
LINQ Tutorial - bit.ly/linqbyni...
Non generic collection in c# - bit.ly/nongener...
Huge respect to you, sir!
Your explanations are excellent, way more better than anyone that I've heard.
After your tutorials I'd really understood what it was all about.
You've made a great job. Thanks a lot for that!
very good sir. waiting for next one.
I could not able to understand how nullable field resolve the int and string compatibility. Can someone please clear this ?Thanks
Kindly make a video how to make model validation in partial view in asp.net core, It's my humble request.
How to override te default validation for types ? When i use double and that I try to write letters in the input i get the default "the value "hdhsk" is not valid", but how can I override this one ? I finded a way with using ModelState.Clear() before using ModelState.AddErrorMessage(...) with simple one field forms but with bigger one it's not so easy...
With int type I can specify type="number" in view input to block the possibility of using letters but this dosn't allow decimals or doubles...
Thanks sir for the tutorial..i have a doubt when you post the data without filling all the required fields, error message is getting displayed that is fine but how does others fields remember their value since you are not passing the model back to the view...
Hi Nitesh
One thing strange i noticed that total page error not showing "Total Page" text and even same thing for me
If I want apply the data annotation validations to be fired on the view load for the first time, how can it be achieved?
What do you mean by "view load for the first time"? . Give some more details.
i have one question sir, do we need validation attributes on the data (not the model) as well?
and can we create database-level validation as well?
Thank you so much been following this tutorial
fucking awesome. keep up
hi sir
modelState.Isvalid is allways false how to resolve it
Make sure there are no null entries in the model for non null properties. Make Category and Language as Nullable then issue will be resolved.
public string? Category { get; set; }
public string? Language { get; set; }
Jquery-validate and Jquery-validation-unobtrusive client-side libraries should be installed as well otherwise it won't work