ModelState.AddModelError is not being displayed inside my view

后端 未结 3 1452
鱼传尺愫
鱼传尺愫 2020-12-13 08:50

I have the following view,, which create 10 ajax.beginform ,, But the problem that i am facing is that incase an error occurs during the creation of the object then the Mode

3条回答
  •  一向
    一向 (楼主)
    2020-12-13 09:28

    @Html.ValidationSummary(true) shows only the error message about model's propertys, if you want to show also the added message, added with

    ModelState.AddModelError(
        "CustomError", 
        "The Same test Type might have been already created, go back to the Visit page to see the avilalbe Lab Tests"); 
    

    you need to set @Html.ValidationSummary(false) If you need to display the validation's message near your input fields you need to set @Html.ValidationSummary(true) and to follow the steps suggested by Syneryx

提交回复
热议问题