Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
| Search | Today's Posts | Mark Forums Read
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
 
Old March 17th, 2005, 12:01 PM
Authorized User
 
Join Date: Mar 2005
Location: , , .
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...

 
Old March 17th, 2005, 01:29 PM
Authorized User
 
Join Date: Mar 2005
Location: Mumbai, Maharastra, India.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try Label lb= new Label();
lb=(Label)TextBox1;

 
Old March 17th, 2005, 10:01 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: India.
Posts: 224
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to ashu_from_india Send a message via Yahoo to ashu_from_india
Default

its not working

 
Old March 18th, 2005, 03:25 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

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.
 
Old March 29th, 2005, 08:26 AM
Friend of Wrox
 
Join Date: Aug 2003
Location: , , .
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to life_s Ng Send a message via MSN to life_s Ng
Default

erm..
how bout play around with tb and lbl 's property VISIBLE?

Cheers
life's Ng

 
Old March 19th, 2010, 11:28 AM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
 
Old September 3rd, 2010, 02:30 AM
Registered User
 
Join Date: Sep 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i think we can do it using the jquery very easily...
 
Old September 3rd, 2010, 10:51 AM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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.
 
Old September 6th, 2010, 04:50 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What makes you think this was an Access question? The question was posted in a general .NET forum, wasn't it?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old September 14th, 2010, 02:14 PM
Registered User
 
Join Date: Mar 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to see a label hombre Java Basics 3 March 4th, 2008 06:15 AM
pointing cursor from one textbox to other textbox lakshmi_annayappa ASP.NET 1.0 and 1.1 Basics 2 August 2nd, 2007 03:41 PM
Convert textbox to picture vemaju Word VBA 0 February 3rd, 2007 08:04 AM
how to access label or textbox in crystalreport howru_sweety Crystal Reports 0 February 27th, 2006 02:44 AM
Masked TextBox & formatting TextBox melvik C# 1 September 22nd, 2003 11:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.