While the toot-tip says,
I tried using it but could not make it to work. I am not sure how it works and about its functionality.
So what purpose does this built-in attribute ReadOnly
serve?
Any inputs will be appreciated. Thank you.
While the toot-tip says,
I tried using it but could not make it to work. I am not sure how it works and about its functionality.
So what purpose does this built-in attribute ReadOnly
serve?
Any inputs will be appreciated. Thank you.
I assume you use this property in a view with something like EditorFor
? Then use:
[Editable(false)]
public string MyProperty {get;set;}
or
@Html.TextBoxFor(x => x.MyProperty, new { readonly = "readonly" })
If you want a readonly public property of a class use:
public string MyProperty {get; private set;}
@Html.EditorFor(
model => model.id_to_fetch,
new {
htmlAttributes = new {
@class = "form-control" , @readonly = "readonly"
}
}
)