Users Pricing

articles

home / developersection / articles / ajax toolkit textboxwatermarkextender control in asp.net

Ajax Toolkit TextBoxWatermarkExtender Control in ASP.Net

Pushpendra Singh 19300 03 Dec 2010 Updated 04 Mar 2020

TextBoxWatermark is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to get watermark behavior. When a watermarked TextBox is empty, it displays a message to the user. Once the user has typed some text into the TextBox, the watermarked appearance disappears.

TextBoxWatermark Properties:

TargetControlID - The ID of the TextBox to operate on

Watermark Text - The text to show when the control has no value

Code:

 <%-- ScriptManager control manages client script for AJAX enabled ASP.NET pages.This enables partial-page rendering and Web-service calls.You have to used this if you want to use ajax control toolkit--%>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%--Add the TextWatermarkExtender here --%>
<cc1:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="TextBox1"WatermarkCssClass="TextWatermarkCss" WatermarkText="Enter Your Name"></cc1:TextBoxWatermarkExtender>
<%--Add the one textbox here --%>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

Add the css in head tag on aspx page

<head><style>
.TextWatermarkCss
{
     color: Gray;
     font-style: italic;
     font-family: Calibri;
}
</style></head>

 

Run the project

Ajax Toolkit TextBoxWatermarkExtender Control in ASP.Net

When you click in the text then watermark text will disappear.

 

Ajax Toolkit TextBoxWatermarkExtender Control in ASP.Net


1 Comments