Adding Style to a Watermark
The TextBoxWatermarkExtender is a powerful tool that allows developers to add watermarks to text boxes on their web pages. These watermarks can be used to provide users with additional context or to prompt them to enter specific types of data.
To add style to a watermark, you can use CSS to define the appearance of the watermark. Here’s an example of how to do this:
.watermark {
color: #999999;
font-style: italic;
}
This CSS code defines a class called “watermark” that sets the color of the text to a light gray (#999999) and sets the font style to italic.
Next, you need to apply this class to the TextBoxWatermarkExtender control. You can do this by setting the “CssClass” property of the control to the name of the CSS class you just defined:
<asp:TextBox ID=”TextBox1″ runat=”server”></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID=”TextBox1Watermark” runat=”server”
TargetControlID=”TextBox1″ WatermarkText=”Enter your name”
CssClass=”watermark” />
This code adds a TextBoxWatermarkExtender control to the page, associates it with the TextBox control using the “TargetControlID” property, sets the watermark text to “Enter your name”, and applies the “watermark” CSS class to the control. When the page is rendered, the watermark text will be displayed in the TextBox control in light gray italic text.
Apply for ASP.NET Certification Now!!
https://www.vskills.in/certification/certified-aspnet-programmer