I have a lot of .aspx pages with a lot of controls. These controls are all declared in a similar way:
<input type="text" runat="server" id="txtLatitude" />
Now I have to check who the user is and, if not allowed to make changes, make all these controls readonly. Normally i would do somethink like
txtLatitude.Attributes.Add("readonly", "readonly")
but it would take me forever to do that manually for each control in each page. I was wondering if there is a way to get a List or something of all the controls with runat="server". I tried using
ControlCollection myControls = Page.Controls
to get them, but I looked at myControls in debug mode and it seems to get a small number of controls, maybe only the controls declared with the asp specific notation , not sure about it.
With said List i would simply do a foreach cycle and add the readonly attribute to each, with a few lines of code. Ideas? (Or maybe I'm just dumb and wasn't able to navigate and search trough myControls in the right way =D )