Clear A Textbox/TextArea On-Entry

I

Iain Wilson

Hi All

I have a number of textboxes and a textarea on a web form - Using C#.

By default each component contains some text - a hint for the user
entering the data.

What I need to do is clear each component as the user's cursor enters
the component - ie I need an On-Entry event -

Can anyone enlighten me as to how I do this

Many thanks in advance for help offered

Iain
 
G

Guest

Hi All

I have a number of textboxes and a textarea on a web form - Using C#.

By default each component contains some text - a hint for the user
entering the data.

What I need to do is clear each component as the user's cursor enters
the component - ie I need an On-Entry event -

Can anyone enlighten me as to how I do this

Many thanks in advance for help offered

Iain

try this

<asp:TextBox ID="TextBox1" OnClientClick="document.getElementById('<%=
TextBox1.ClientID %>').value='';"
 
E

Eliyahu Goldin

Don't think there is an OnClientClick event for the textbox.

This markup
<asp:TextBox ID="TextBox1" onfocus="this.value='';" />
will work but will cause the designer to complain.

This code-behind
TextBox1.Attributes["onfocus"]="this.value='';";
will work with no complains

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net


Hi All

I have a number of textboxes and a textarea on a web form - Using C#.

By default each component contains some text - a hint for the user
entering the data.

What I need to do is clear each component as the user's cursor enters
the component - ie I need an On-Entry event -

Can anyone enlighten me as to how I do this

Many thanks in advance for help offered

Iain

try this

<asp:TextBox ID="TextBox1" OnClientClick="document.getElementById('<%=
TextBox1.ClientID %>').value='';"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top