For that, I'd inject a little client-side JavaScript into the page that
checks the current text when the control gets the focus. If it is the same
as the default text, set it to an empty string.
Here's the idea:
Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim strDefaultText = "The default text"
If Not IsPostBack Then
TextBox1.Text = strDefaultText
End If
TextBox1.Attributes.Add("onfocus", "doClear(this)")
Page.RegisterClientScriptBlock("clear", _
"<script language='javascript'>function doClear(cntrl)" & _
"{if (cntrl.value=='" & _
strDefaultText & "'){cntrl.value=''}}</script>")
End Sub
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.