Model Warnings in ASP.NET MVC

后端 未结 3 592
名媛妹妹
名媛妹妹 2021-02-06 10:13

I\'m currently using the ModelStateDictionary in asp.net mvc to hold validation errors and pass then back to the user. Being able to check if the whole model is valid with Model

3条回答
  •  旧巷少年郎
    2021-02-06 11:09

    Why not simply add a list of warnings, or a dictionary, to the ViewData and then display them in your view?

    e.g.

    ViewData[ "warnings" ] = new[] { "You need to snarfle your aardvark" } ;
    

提交回复
热议问题