data annotations hide property/field

给你一囗甜甜゛ 提交于 2019-12-04 08:10:16

just found the answer actually..

[HiddenInput(DisplayValue = false)] works but I had to add:

using System.Web.Mvc;

as for me, when I'm used

[HiddenInput(DisplayValue = false)]

to my model props I still got displaying in schaffolded Create/Edit views. When I was just removing that code from view - yes, it wasn't visible any more, but after saving edits I got another problem: props for what I remove editors change their values to null. I use this on edit views to fix it

@Html.HiddenFor(model => model.ImageUrl)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!