Questions tagged [readonly]

Read-only is a generic concept that means "not writeable" - Please DO NOT USE THIS TAG. This tag is ambiguous and needs to be broken up.

This tag is ambiguous.

Please consider using (or creating) alternate tags for the specific use-cases of this term.

  • Read-only is a generic concept that means "not writeable"

  • readonly is a language keyword in C# that makes a member immutable.

  • readonly is an HTML attribute that makes input elements non-editable.

1624 questions
113
votes
8 answers

How to implement a read only property

I need to implement a read only property on my type. Moreover the value of this property is going to be set in the constructor and it is not going to be changed (I am writing a class that exposes custom routed UI commands for WPF but it does not…
akonsu
  • 28,824
  • 33
  • 119
  • 194
101
votes
14 answers

Readonly models in Django admin interface?

How can I make a model completely read-only in the admin interface? It's for a kind of log table, where I'm using the admin features to search, sort, filter etc, but there is no need to modify the log. In case this looks like a duplicate, here's not…
Steve Bennett
  • 114,604
  • 39
  • 168
  • 219
99
votes
7 answers

Readonly Properties in Objective-C?

I have declared a readonly property in my interface as such: @property (readonly, nonatomic, copy) NSString* eventDomain; Maybe I'm misunderstanding properties, but I thought that when you declare it as readonly, you can use the generated setter…
Alex
  • 64,178
  • 48
  • 151
  • 180
96
votes
3 answers

Immutable numpy array?

Is there a simple way to create an immutable NumPy array? If one has to derive a class from ndarray to do this, what's the minimum set of methods that one has to override to achieve immutability?
NPE
  • 486,780
  • 108
  • 951
  • 1,012
95
votes
10 answers

Can parameters be constant?

I'm looking for the C# equivalent of Java's final. Does it exist? Does C# have anything like the following: public Foo(final int bar); In the above example, bar is a read only variable and cannot be changed by Foo(). Is there any way to do this in…
Nick Heiner
  • 119,074
  • 188
  • 476
  • 699
92
votes
9 answers

OneWayToSource binding from readonly property in XAML

I'm trying to bind to a Readonly property with OneWayToSource as mode, but it seems this cannot be done in XAML:
Inferis
  • 4,582
  • 5
  • 37
  • 47
86
votes
7 answers

Open a file in a tab in vim in readonly mode

I'm aware of opening files in readonly mode from shell using vim -R, but how to open a file from inside vim in a separate tab (:tabe ) in readonly mode? Thanks for your time.
Srikanth
  • 11,780
  • 23
  • 72
  • 92
76
votes
5 answers

Which is better between a readonly modifier and a private setter?

I've been working on creating a class and suddenly a thought came to my mind of what is the difference between the two codes: public readonly string ProductLocation; AND public string ProductLocation { get; private set; } Can you guys…
Allan Chua
  • 9,305
  • 9
  • 41
  • 61
72
votes
12 answers

MVC3 EditorFor readOnly

I want to make readOnly with EditorFor in edit page. I tried to put readonly and disabled as:
@Html.EditorFor(model => model.userName, new { disabled = "disabled", @readonly = "readonly" })
However, it…
wholee1
  • 1,491
  • 13
  • 34
  • 51
70
votes
7 answers

How to make readonly all inputs in some div in Angular2?

I have a page with many inputs, and I want to make it 'readOnly' I find this solution: How to change HTML element readonly and required attribute in Angular2 Typescript? But I don't want to do it for every input separately. How can I add readOnly…
John Doe
  • 3,794
  • 9
  • 40
  • 72
67
votes
8 answers

What's the best way of creating a readonly array in C#?

I've got the extremely unlikely and original situation of wanting to return a readonly array from my property. So far I'm only aware of one way of doing it - through the System.Collections.ObjectModel.ReadOnlyCollection. But that seems somehow…
Vilx-
  • 104,512
  • 87
  • 279
  • 422
67
votes
9 answers

How to make a input field readonly with JavaScript?

I know you can add readonly="readonly" to an input field so its not editable. But I need to use javascript to target the id of the input and make it readonly as I do not have access to the form code (it's generated via marketing software) I don't…
chris
  • 861
  • 1
  • 7
  • 15
66
votes
4 answers

What is the correct readonly attribute syntax for input text elements?

As Most, I am familiar with the readonly attribute for text input, But while reading code from other websites (a nasty habit of mine ) I saw more than one implementation for this attribute:
Obmerk Kronen
  • 15,619
  • 16
  • 66
  • 105
64
votes
7 answers

asp:TextBox ReadOnly=true or Enabled=false?

What's the difference between the Enabled and the ReadOnly-properties of an asp:TextBox control?
Alf
  • 1,518
  • 3
  • 17
  • 21
64
votes
10 answers

How to make a git repository read-only?

I have some git repositories accessed remotely through SSH and I want to make some of them read-only to prevent more pushes. Some people have remotes pointing to these repositories. These bare repositories were initialised --shared=group, so is…
Steve Folly
  • 8,327
  • 9
  • 52
  • 63