开发者

ASP.NET MVC is there an attribute for a ViewModel/Dto property which causes the modelbinder/view to ignore it?

开发者 https://www.devze.com 2022-12-31 10:49 出处:网络
I have a property in a dto that I don\'t want the modelbinder/view to use the get on? I开发者_C百科s there an attribute I can decorate it with to stop them from interrogating it?

I have a property in a dto that I don't want the modelbinder/view to use the get on? I开发者_C百科s there an attribute I can decorate it with to stop them from interrogating it?

Thanks


public class Model
{
  [Bindable(false)] // this is the attribute you can use...
  public int ModelId { get; set; }
}


See the "Include" and "Exclude" properties on the BindAttribute:

http://msdn.microsoft.com/en-us/library/system.web.mvc.bindattribute_members.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消