Ajax controltoolkit Learning Log-textboxwatermarkextender (28)

Source: Internet
Author: User
Textboxwatermarkextender is used to add watermarks to textbox.

See an example below:

1) Create an ASP. NET Ajax-enabeld web project in vs2005 and name it textboxwatermarkextender1.

2) Add two textbox in default. aspx for firstname and lastname respectively. Add a textboxwatermarkextender control to each textbox to add the watermark effect.

CodeAs follows:

1 Firstname: & Nbsp;
2 < ASP: textbox ID = "Txtfirstname" Runat = "Server" Cssclass = "Unwatermarked" > </ ASP: textbox > & Nbsp;
3 < C0: textboxwatermarkextender ID = "Textboxwatermarkextender1" Runat = "Server" Targetcontrolid = "Txtfirstname" Watermarkcssclass = "Watermarked" Watermarktext = "Please input the first name" > </ C0: textboxwatermarkextender >
4 < BR />
5 Lastname: & Nbsp;
6 < ASP: textbox ID = "Txtlastname" Runat = "Server" Cssclass = "Unwatermarked" > </ ASP: textbox >
7 < C0: textboxwatermarkextender ID = "Textboxwatermarkextender2" Runat = "Server" Targetcontrolid = "Txtlastname" Watermarkcssclass = "Watermarked" Watermarktext = "Please input the last name" > </ C0: textboxwatermarkextender >
8 < BR />


Attribute description:

Targetcontrolid: The target associated control of the control.
Watermarkcssclass: The CSS style that produces the watermark effect.
Watermarktext: The text on the watermark when the watermark effect is available.

3) The key CSS style to see the watermark effect.

The Code is as follows:

1 . Watermarked {} {
2 Height : 20px ;
3 Width : 150px ;
4 Padding : 2px 0 0 2px ;
5 Border : 1px solid # bebebe ;
6 Background-color : # F0f8ff ;
7 Color : Gray ;
8 }

4) add an updatepanel control on the page and add a button and label to the control to display user input.

The Code is as follows: 1 < ASP: updatepanel ID = "Updatepanel1" Runat = "Server" >
2 < Contenttemplate >
3 < ASP: button ID = "Button1" Runat = "Server" Onclick = "Button#click" Text = "Submit"   />
4 < BR />
5 < BR />
6 < ASP: Label ID = "Message" Runat = "Server" > </ ASP: Label >
7 </ Contenttemplate >
8 </ ASP: updatepanel >

Code for processing the button: This . Message. Text =   " Welcome: "   +   This . Txtfirstname. Text +   "   "   +   This . Txtlastname. text;

5) press Ctrl + F5 to view the effect in the browser.

As follows:

Related Article

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.