Answered by:
ReadOnly Controls

Question
-
User2012067485 posted
Hello,
I'm currently looking for some controls that render readonly content as span's rather than the original control. i.e. a readonly textbox would be rendered as <span>Text Value</span> rather than <input type="text" value="Text Value" />. I started implementing the textbox example myself which works fine until I brought validators into the equation which fail if the textbox is empty.
Does anyone have any thoughts about a control library that does this?
Thanks
Neil
Sunday, June 8, 2008 11:50 AM
Answers
-
User1564875471 posted
I think the best solution is to write a userControl , create a public proeprty for that control and let the usercontrol behave based on that property ,
so if you need a readonly text , you set the property value to readonly , which inform the usercontrol to render as a label ,
And set that property to Edit , to inform the label to render as textbox !
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 8, 2008 4:03 PM -
User-16411453 posted
The label Control just renders <span></span> tags.
The panel control just renders <div></div> tags.
Most controls don't really do anything special, but just render common tags in the proper format, HTML 4.0, XHTML 1.0, whatever you set the WebForm To.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 8, 2008 5:24 PM
All replies
-
User1564875471 posted
why you don't use the label ?Sunday, June 8, 2008 3:26 PM -
User2012067485 posted
Hello,
This is how we are currently working though this is a time cunsuming task as when we add new pages into the system or new fields onto a existing page. This also leads to a lot of unnecessary code which is just performing the same task of detecting whether the page should be readonly and if so hiding the current input field and displaying a label instead.
The way I see it a group of controls which inherit of the standard textbox, dropdownlist, checkbox(s) and radio button(s) would provide this functionaility without all the code.
Thanks
Neil
Sunday, June 8, 2008 3:40 PM -
User1564875471 posted
I think the best solution is to write a userControl , create a public proeprty for that control and let the usercontrol behave based on that property ,
so if you need a readonly text , you set the property value to readonly , which inform the usercontrol to render as a label ,
And set that property to Edit , to inform the label to render as textbox !
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 8, 2008 4:03 PM -
User-16411453 posted
The label Control just renders <span></span> tags.
The panel control just renders <div></div> tags.
Most controls don't really do anything special, but just render common tags in the proper format, HTML 4.0, XHTML 1.0, whatever you set the WebForm To.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, June 8, 2008 5:24 PM