ASP.net Convert text box to label with code

Murray Brown
Murray Brown used Ask the Experts™
on
In ASP.net is it possible to convert a text box to a label using code
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software Team Lead
Commented:
In ASP.net is it possible to convert a text box to a label using code
not really....you can't do that.

what is your intention here?
if you mean to initially to have a Text Box for data entry, and then once it's posted back, show what was entered as Label with static value, then you can have a TextBox (with Visible = True) for data entry (while a Label with Visible = False initially), once it's posted, make the TextBox's visible to False, and pass the value of TextBox to Label, and finally set the Label's Visible to True.
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
TextBox t = new TextBox();
Label l = new Label();
Control c = (Control) t;
c = (Control) l;

Open in new window

https://www.codeproject.com/Questions/381865/how-to-cast-a-control-to-button-textbox-or-label
Murray BrownASP.net/VSTO Developer

Author

Commented:
Thank you both

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial