Click here to Skip to main content
Licence CPOL
First Posted 24 Mar 2006
Views 31,088
Downloads 142
Bookmarked 42 times

Creating a watermark ("") textbox control

By PuReBRaiNZ | 24 Mar 2006
This article describes the implementation of a watermark textbox control.

1
3 votes, 25.0%
2
3 votes, 25.0%
3
4 votes, 33.3%
4
2 votes, 16.7%
5
3.24/5 - 12 votes
μ 3.24, σa 1.90 [?]

Sample Image - WatermarkTextBoxControl.jpg

Introduction

This article shows the source code required to create a textbox control which will show a default string when no content is entered. This can be a useful feature when you need to guide a user in filling in the required data in a web form.

Typical uses of this control include showing "< enter your text here >" or "< search terms >" in gray in a search box in a web page.

The control shows the text when no content is entered, and removes the text when the control receives focus (when the textbox is selected by mouse or by pressing tab, in the onFocus event). When the control loses focus (in the onBlur event), when no text is entered, the watermark text is again inserted in the textbox.

Usage

Typical usage of this control is demonstrated here:

<%@ Register TagPrefix="WeSeeSc" 
  Namespace="We.See.Web.ServerControls" Assembly="ServerControls" %>

Search:
<WeSeeSc:WatermarkTextBox id="query" Runat="server" 
  Watermark="< enter your question >"></WeSeeSc:WatermarkTextBox></TD>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

PuReBRaiNZ



Netherlands Netherlands

Member
PuReBRaiNZ has been programming in all microsoft supported languages for nearly ten years. His current job is in ms (asp.net & sql) consultancy in the Netherlands.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionPassword mode not supported Pinmemberrlaemmler5:27 29 May '07  
GeneralNice Idea PinmemberSteve Maier5:18 24 Mar '06  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120210.1 | Last Updated 24 Mar 2006
Article Copyright 2006 by PuReBRaiNZ
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid