green field

WatermarkTextbox

The WatermarkTextbox is used for the SearchInput control in mojoPortal, it allows you to display some text in a textbox to help prompt the user for the expected input, but as soon as the user clicks in the textbox, the watermark text disappears allowing the user to enter their own input. Notice on this site the Search Input at the top of the page has "enter search terms", but as soon as you click in the input the text goes away.

mojoPortal already includes the mojoPortal Web Controls, but if you would like to use them in a different project, you can download mojoportalwebcontrols-x-x-x.zip from this page on Novell Forge

To use this control you need to put the mojoPortal.Web.Controls.dll into the bin folder of your application and set a reference to it. Then in your web.config file, in the system.web pages section add a control declaration like this:

mojowebcontrols config example

And here is the markup for adding a WatermarkTextbox control:



You need to tell the control where to find its javascript using the ScriptDirectory property, and you can set the Watermark property to indicate the text that should display until the user clicks in the textbox. You can also set a CSS class to style it. My CSS class looks like this:
.watermarktextbox { color:Gray; }

The watermarktextbox.js file must exist in the location specified by ScriptDirectory.

You can also set properties in code behind like this:
this.txtSearch.Watermark = "enter search terms";

and you can retireve the value entered by the user from this.txtSearch.Text, just like a normal textbox.
Event Calendar Pro a better event calendar for mojoportal
 
Vote for mojoPortal in the 2008 CMS Awards