Saturday, 26 July 2014

TextBoxWatermark Contol Of AjaxControlToolKit For Displaying Watermark in TextBox In Asp.Net

7/26/2014 - By Pranav Singh 0

Water mask is used for displaying message I a control to user that what he need to enter in it. So in this article I will show you how you can display watermark in a textbox using TextBoxWatermark Contol Of AjaxControlToolKit in asp.net.


So for this article first we will create  a new asp.net application in it’s page we will add a textbox , TextBoxWatermark,  ScriptManager control. Now check the below code.


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ControlValidationByAjaxControltoolKit.Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>TextBoxWatermark Contol Of AjaxControlToolKit For Displaying Watermark in TextBox In Asp.Net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        Enter Name:<asp:TextBox ID="TextBox1" runat="server" Width="189px"></asp:TextBox>
        <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID="TextBox1" WatermarkText="Please enter name">
        </asp:TextBoxWatermarkExtender>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    </div>
    </form>
</body>
</html>

So for displaying the watermark text we have to define the following properties of TextBoxWatermark.

TargetControlID="TextBox1"
 WatermarkText="Please enter name

Now check the propertied of water mark textbox.

  • TargetControlID - The ID of the TextBox to operate on
  • WatermarkText - The text to show when the control has no value
  • WatermarkCssClass - The CSS class to apply to the TextBox when it has no value (e.g. the watermark text is shown).
So we have done


DOWNLOAD

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top