List Info

Thread: C-Sharp (C#) Group: Text Box Properties




C-Sharp (C#) Group: Text Box Properties
user name
2006-01-30 16:09:56
Just a simple question, when something is entered into the
'text'
property of a text box in visual studio, how can i make the
text
dissappear as soon as the user selects the box?

Thanks for your time

Twigg

C-Sharp (C#) Group: Re: Text Box Properties
user name
2006-01-30 16:12:17
Use the enter event for the control

> -----Original Message-----
> From: C_Sharpgooglegroups.com [mailto:C_Sharpgooglegroups.com] On Behalf
> Of Twigg
> Sent: Monday, January 30, 2006 10:10 AM
> To: C-Sharp (C#)
> Subject: C-Sharp (C#) Group: Text Box Properties
> 
> 
> Just a simple question, when something is entered into
the 'text'
> property of a text box in visual studio, how can i make
the text
> dissappear as soon as the user selects the box?
> 
> Thanks for your time
> 
> Twigg

C-Sharp (C#) Group: Re: Text Box Properties
user name
2006-01-30 16:22:48
I am assuming you mean on the web rather then in windows (since in windows its so piddly), assuming your TextBox ID is "f_tbNotes" add this to your code behind:

f_tbNotes.Attributes.Add("onclick";, "if(this.value == 'Whatever the default value is') this.value = '';");

changing "Whatever the default value is" for whatever you have set the default value for. If you want it to clear every time it is clicked (won't care if the user has entered text or not) use this instead:

f_tbNotes.Attributes.Add("onclick", "this.value = '';");

Liam


On 1/30/06, Twigg < charlestwiggyahoo.co.uk">charlestwiggyahoo.co.uk> wrote:

Just a simple question, when something is entered into the 'text'
property of a text box in visual studio, how can i make the text
dissappear as soon as the user selects the box?

Thanks for your time

Twigg



C-Sharp (C#) Group: Re: Text Box Properties
user name
2006-01-30 20:27:38
Thank you for the accurate response Liam, one more question,
if the
text box has a requiredfieldvalidator associated with it how
can i get
it to ignore the default value in the box?

Any help would be great!

Twigg

C-Sharp (C#) Group: Re: Text Box Properties
user name
2006-01-30 20:37:07
The best way of doing it would be to use a Custom Validator. Take a look at http://aspnet.4guysfromrolla.com/articles/073102-1.aspx
 
Liam

&nbsp;
On 1/30/06, Twigg < charlestwiggyahoo.co.uk">charlestwiggyahoo.co.uk> wrote:

Thank you for the accurate response Liam, one more question, if the
text box has a requiredfieldvalidator associated with it how can i get
it to ignore the default value in the box?

Any help would be great!

Twigg
C-Sharp (C#) Group: Re: Text Box Properties
user name
2006-01-30 20:41:06
Write code to handle, 

if(textbox.text != "my required data") { /* do
something */ return; }

or if there are multiple possible values,

switch(textbox.text)
{
	case "value1":
		/* do something */
		break;
	case "value2":
		....
		break;
	default:
		/* error, invalid data */
		break;
}

> -----Original Message-----
> From: C_Sharpgooglegroups.com [mailto:C_Sharpgooglegroups.com] On Behalf
> Of Twigg
> Sent: Monday, January 30, 2006 2:28 PM
> To: C-Sharp (C#)
> Subject: C-Sharp (C#) Group: Re: Text Box Properties
> 
> 
> Thank you for the accurate response Liam, one more
question, if the
> text box has a requiredfieldvalidator associated with
it how can i get
> it to ignore the default value in the box?
> 
> Any help would be great!
> 
> Twigg

[1-6]

about | contact  Other archives ( Real Estate discussion Medical topics )