textbox - ASP.NET - Swap TextBoxes for Labels when Enabled=False -
Setup: Web form with lots of text box controls
When I enable the property of the wrong property of any text box control, I want to "swap" that text box for a label on the runtime. This idea is here that if it reads just like that, do not display it in the design designed for editing.
I think it should be very simple and reusable, but what is the best way to do it?
Not sure that its the best way, I will create a text box with a custom server control, / P>>
Then override the render method, check that it is read only,
If it is read only then it is necessary to present your Span Tag like label controls.
If not, then render on the base (textbox) ...
public class specialtaxbox: textbox {public override recourse control (HtmlTextWriter author) {if (! ReadOnly) {base.RenderControl (writer); } Other {author. Light (string.format ("& lt; span id = \" {0} \ "class = \" {1} \ "& gt; {2} ", This .client id, this .css class, this text.)); }}}
Comments
Post a Comment