published 2 years, 11 months ago, submitted by
RobChappel
2 years, 11 months ago
aspnet.4guysfromrolla.com — A common pattern in data-driven Web applications is that of the read-only user interface. Often a website contains a page that displays records from a database that, by default, the visitor can edit. However, there are times when the data is not editable, and needs to be displayed in a read-only interface. Deciding whether or not to display the user interface in read-only mode can be dependent on any number of factors. Perhaps only certain users can edit the data, while others can only view it, or perhaps the data can only be edited by the person who added the particular information, or maybe there's some sort of expiration date, after which the data can no longer be edited.
Regardless of why the data may or may not be read-only, there are two general techniques that can be used to implement such an interface on a single ASP.NET page. The prettiest, most intuitive way is to display textboxes, drop-down lists, checkboxes, and so on for editable data and plain-text for read-only data. This approach, of course, takes a little bit of extra work since for each input both an input Web control needs to be added to the page as well as a Label, and then the appropriate control needs to be shown or hidden based on whether or not the data is editable. Most developers opt for a somewhat simpler approach and use disabled or read-only textboxes, drop-down lists, and checkboxes. With this second approach, there's just one user interface, but the developer sets the Enabled or ReadOnly properties of the Web controls based on whether or not the data is editable
|
|