Pre-loading a textbox with content can be used to indicate the format of the text to be entered. Instructions within the textbox can create a cleaner website.
For a cleaner, minimalist website moving the instruction words within a text box reduces the clutter on a page.
where space on the web page is at a premium putting the text within the box can save on the surrounding space.
An example of this is a search box with a magnifying glass to click, and words such as Search within.
Adding text in a textbox can help to show the website visitor the type of entry which you are expecting. For example the date format or time format hh:mm.
The aim is to be able to have some initial text within a textbox to illustrate
its purpose. In this example a textbox shall be pre-populated with the time layout. It will also be given a silver colour to illustrate that its guidance text.
The ASP.NET textbox is defined as :
<asp:TextBox id=”tbxStartTime” ForeColor=”silver” Columns=”5″
runat=”server” >HH:MM</asp:TextBox>
When the user clicks within the textbox we want to remove our helpful text, and
reset the colour from silver. In our code behind we have:
tbxStartTime.Attributes.Add(“OnClick”, “this.value=”;this.style.color= ”;”)


