PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Clear A Textbox/TextArea On-Entry

 
 
Iain Wilson
Guest
Posts: n/a
 
      28th Feb 2008
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
 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      28th Feb 2008
On Feb 28, 9:14*am, Iain Wilson <Email.IainWil...@gmail.com> wrote:
> 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='';"
 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      28th Feb 2008
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


"Alexey Smirnov" <(E-Mail Removed)> wrote in message
news:593c1181-4a35-435f-a8b1-(E-Mail Removed)...
On Feb 28, 9:14 am, Iain Wilson <Email.IainWil...@gmail.com> wrote:
> 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='';"


 
Reply With Quote
 
Iain Wilson
Guest
Posts: n/a
 
      28th Feb 2008


The onfocus Event work a treat.
Thanks to all for the help

Iain
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[2008] Clear contents of textbox, reverting transaction with textbox method undo Rob W Microsoft VB .NET 0 6th Mar 2009 10:39 AM
Textbox Clear last entry Corey Microsoft Excel Programming 1 21st Nov 2006 07:17 AM
Textbox clear elli Microsoft Access Forms 1 26th Feb 2006 05:45 PM
Clear a textbox Stuart Microsoft Excel Programming 2 12th Jul 2004 08:29 PM
remembering last position in textbox / textarea and returning to after post / reload jason@cyberpine.com Microsoft ASP .NET 3 5th Oct 2003 06:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:38 PM.