Use the ASP. NET Ajax-textboxwateramrk Control

Source: Internet
Author: User
Document directory
  • Introduction
  • Important attributes
  • Example
Introduction

The textboxwatermark control is a watermark control used for textbox. Before entering text in the text box, there are some prompt text in the text box, and you can customize CSS to control its style, I don't think it is very useful, but it brings convenience to users and good visual effects.

Important attributes

Targetcontrolid: ID of the text box to apply the watermark Effect
Watermarktext: the prompt Text of the watermark effect.
Watermarkcssclass: CSS style used for watermark Effect

Example

1. Open vs2005 and create an ajaxcontroltoolkit website named oec2003_textboxwatermark.
2. Open the default. aspx page and switch to the design view.
3. Add two text boxes and two textboxwatermark controls, as shown in figure

4. Switch to the Code view and set the attributes of the textboxwatermark control. The Code is as follows:

<Ajaxtoolkit: textboxwatermarkextender id = "textboxwatermarkextender1" runat = "server" targetcontrolid = "textbox2" watermarktext = "Enter the user name" watermarkcssclass = "water1"> </ajaxtoolkit: authorization> <ajaxtoolkit: textboxwatermarkextender id = "Courier" runat = "server" watermarktext = "enter the password" targetcontrolid = "textbox1" Highlight = "water2"> </ajaxtoolkit: textboxwatermarkextender>

5. Add the following CSS:

<style type="text/css"> .water1 {     height:20px;     width:150px;     padding:2px 0 0 2px;     border:1px solid #BEBEBE;     background-color:#F0F8FF;     color:red;}.water2{    height:20px;    width:150px;    border:1px none #ffffcc;    background-color:#ccccff;    color:green;}</style>

Here is just a simple bit of CSS. You can also use CSS to write beautiful watermarks.
Save the design and run the program to see the effect. When you click the text box, the watermark disappears, the cursor appears in the text box, And the watermark appears again after the mouse leaves.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.