Created
June 27, 2018 15:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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;} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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