ASP.Net [HiddenInput] Data Attribute not working when rendered with Html.EditorForModel in Razor?

后端 未结 6 629
情歌与酒
情歌与酒 2021-01-11 18:01

I have the following model:

public class Product
{
    [HiddenInput(DisplayValue = false)]
    public int ProductID { get; set; }

    [Required(ErrorMessage         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-11 18:52

    If you use scaffolding the generator will set the input tag with the type hidden in your view. This depends on the T4 Template.

    If you create the view manually you must set the field manually. e.g

    @Html.HiddenFor(model => model.Id)
    

提交回复
热议问题