 |
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

March 17th, 2005, 12:01 PM
|
Authorized User
|
|
Join Date: Mar 2005
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
you can not convert them like we convert an interger to a string, but if you want to convert a label, so first persist all the values realated to the label(like text, size, position etc) in some temp variables and then use these values for the textbox.
hope it helps...
|

March 17th, 2005, 01:29 PM
|
Authorized User
|
|
Join Date: Mar 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
try Label lb= new Label();
lb=(Label)TextBox1;
|

March 17th, 2005, 10:01 PM
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
|
|
its not working
|

March 18th, 2005, 03:25 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Of course it's not working, because it's not possible to cast a TextBox to a Label. They both are Controls, but neither of them is lower in the chain of inheritance of the other so you can't cast it up. You wouldn't expect this to work, would you?
Pear myPear = (Pear) myBanana;
However, this would work:
(Fruit) myFruit = (Fruit) myBanana;
because a banana ultimatly inherits from fruit.
All you can do is follow the suggestions made by others. Change the behavior of the TextBox so it looks like a Label, or create a new Label and copy the Text property of the TextBox over to the Label.
Alternatively, demand that your interviewers ask relevant or logical questions at interviews. But maybe this was a nice trick question, trying to find out what you knew about the subject....
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|

March 29th, 2005, 08:26 AM
|
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
erm..
how bout play around with tb and lbl 's property VISIBLE?
Cheers
life's Ng
|

March 19th, 2010, 11:28 AM
|
Registered User
|
|
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
In design view, right click the text box or label
In design view, you can right-click a text box or a label and choose to convert it. I trust this is the answer that the interviewer was looking for.
Cheers
|

September 3rd, 2010, 02:30 AM
|
Registered User
|
|
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
i think we can do it using the jquery very easily...
|

September 3rd, 2010, 10:51 AM
|
Registered User
|
|
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The interviewer was asking a standard Access question
The original question that was asked in the interview pertained to microsoft access, not microsoft .net nor ASP.net. This is a normal interviewing question intended to find out if you have expertise in Access form design.
The response they were looking for was "In Microsoft Access, in the form design view, you right click the text box and from the drop down menu choose convert to label, or vice versa".
This is a dot net forum, and the responders are helpfully and intelligently trying to figure out a way to convert text boxes to labels. I respect your helpful attitude, but please stop torturing yourselves.
Moderator, would you close this thread please.
|

September 6th, 2010, 04:50 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What makes you think this was an Access question? The question was posted in a general .NET forum, wasn't it?
Imar
|

September 14th, 2010, 02:14 PM
|
Registered User
|
|
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The reason I think this is an Access question is this:
Asking someone how to convert between text boxes and labels is a normal interview question...if the interview is about Microsoft Access.
The question makes no sense in ASP.net; realistically, why wouldn't you just delete the text box and create a new label? Unless the interviewer was clueless, which is entirely possible, the interview had to have been about Access.
Ashu from India, help me out here. What exactly were you interviewing for?
Was it Microsoft Access developer?
No disrespect intended to anyone. You are all nice people, and smart too.
|
|
 |