(#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...

ความคิดเห็น • 15

  • @dmytroskydanenko5106
    @dmytroskydanenko5106 4 ปีที่แล้ว +2

    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!

  • @pp-zc4to
    @pp-zc4to 4 ปีที่แล้ว

    very good sir. waiting for next one.

  • @SaurabhKumar-om2gz
    @SaurabhKumar-om2gz 2 ปีที่แล้ว

    I could not able to understand how nullable field resolve the int and string compatibility. Can someone please clear this ?Thanks

  • @anuragmohanty1301
    @anuragmohanty1301 2 ปีที่แล้ว

    Kindly make a video how to make model validation in partial view in asp.net core, It's my humble request.

  • @maximilianponiatowski4745
    @maximilianponiatowski4745 2 ปีที่แล้ว

    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...

    • @maximilianponiatowski4745
      @maximilianponiatowski4745 2 ปีที่แล้ว

      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...

  • @bhagwatshahi7244
    @bhagwatshahi7244 3 ปีที่แล้ว

    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...

  • @funwithvanshika4405
    @funwithvanshika4405 4 ปีที่แล้ว

    Hi Nitesh
    One thing strange i noticed that total page error not showing "Total Page" text and even same thing for me

  • @saikrishnak6872
    @saikrishnak6872 3 ปีที่แล้ว

    If I want apply the data annotation validations to be fired on the view load for the first time, how can it be achieved?

    • @WebGentle
      @WebGentle  3 ปีที่แล้ว

      What do you mean by "view load for the first time"? . Give some more details.

  • @wahyumaulanaakbar7920
    @wahyumaulanaakbar7920 3 ปีที่แล้ว

    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

  • @asadbekkhasanov6578
    @asadbekkhasanov6578 4 ปีที่แล้ว

    fucking awesome. keep up

  • @vangpallysrinivas6982
    @vangpallysrinivas6982 2 ปีที่แล้ว

    hi sir
    modelState.Isvalid is allways false how to resolve it

    • @amannayyar5124
      @amannayyar5124 ปีที่แล้ว

      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; }

  • @aayushpatel3152
    @aayushpatel3152 2 ปีที่แล้ว

    Jquery-validate and Jquery-validation-unobtrusive client-side libraries should be installed as well otherwise it won't work