Jquery dialog partial view server side validation on Save button click

后端 未结 2 1217
萌比男神i
萌比男神i 2020-11-30 10:40

I have a table that displays data. Each row of table has Edit button. When edit button is clicked a jquery dialog appears with Form for editing the user info and save and ca

2条回答
  •  悲&欢浪女
    2020-11-30 11:19

    Hi without writing any Jscript we can us inbuilt unobstrusive features. as below.

    Model

        Public class Model{[Required(ErrorMessage = "Required.")]
       [Range(0, int.MaxValue, ErrorMessage = "Please enter a Number")]
       public int NumberOfPosters { get; set; }}
    

    Partial View

        @Html.TextBoxFor(model => model.NumberOfPosters, new { style="width:150px;"})
         @Html.ValidationMessageFor(model => model.NumberOfPosters)
    

提交回复
热议问题