Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created June 27, 2018 15:30
Show Gist options
  • Save csharpforevermore/9076ffe79be499348691552db2696933 to your computer and use it in GitHub Desktop.
Save csharpforevermore/9076ffe79be499348691552db2696933 to your computer and use it in GitHub Desktop.
MVC Model Validation - have a property that doesn't get posted back. Sourced
[Editable(false)]
public string MyProperty {get;set;}
// OR
// If you want a readonly public property of a class use:
public string MyProperty {get; private set;}
@Html.TextBoxFor(x => x.MyProperty, new { readonly = "readonly" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment