Sunday, 23 December 2018

readonly attributes

This attribute is used to make a property read-only. We can still able to change the property value on the view, but once we post the form the model binder will respect the readonly attribute and will not move the value to the property.  

You can also, make the property of a class readonly simply, by removing the SET accessor. 

ReadOnly attribute is present in System.ComponentModel namespace.

    [ReadOnly(true)]
    [DataType(DataType.EmailAddress)]
    public string EmailAddress { get; set; }

No comments:

Post a Comment