Click here to Skip to main content
12,885,163 members (33,260 online)
Click here to Skip to main content
Add your own
alternative version


Posted 30 Apr 2012

JavaScript watermark in place of Ajax watermark in ASP.NET with C#

, 30 Apr 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
Provides a simple and easy way to use water mark in your application


this code is basically provide a way to users to apply the water mark on there application using simple java script functions  

Using the code 

just simply use this code given below or download its zip file and enjoy the javascript water mark in your application  

<html xmlns="">
<head runat="server">
<script type="text/javascript"

    <style type="text/css">
         font-family: Tahoma, Arial, sans-serif;
    <script type="text/javascript">
        $(function() {
            $(".water").each(function() {
                $tb = $(this);
                if ($tb.val() != this.title) {
            $(".water").focus(function() {
                $tb = $(this);
                if ($tb.val() == this.title) {
            $(".water").blur(function() {
                $tb = $(this);
                if ($.trim($tb.val()) == "") {
    <form id="form1" runat="server">
    <div class="smallDiv">
     <h2>TextBox Watermark Demonstration</h2>    <br />          
        <asp:TextBox ID="txtFNm" class="water" Text="Type your First Name"

        Tooltip="Type your First Name" runat="server"></asp:TextBox><br />
        <asp:TextBox ID="txtLNm" class="water" Text="Type your Last Name"

        Tooltip="Type your Last Name" runat="server"></asp:TextBox>
        <br /><br />
        <asp:TextBox ID="TextBox1" runat="server" class="water" Text="Name" 

        <br />
        <br />
        <asp:TextBox ID="TextBox2" runat="server" class="water" Text="Password" 

        <br />
        <br />
        <br />
        <asp:Button ID="btnSubmit" runat="server" Text="Submit" 

            onclick="btnSubmit_Click" />
        <br /><br />
        Tip: Click on the TextBox to start typing. The watermark
        text disappears.

just  copy and paste this above code or use zip file to complete your requirement regarding water mark in any application  


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
India India
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 2 Pin
John Kasra27-May-12 11:53
memberJohn Kasra27-May-12 11:53 
QuestionArticle or Tip? Pin
Manfred R. Bihy30-Apr-12 2:24
mvpManfred R. Bihy30-Apr-12 2:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170424.1 | Last Updated 30 Apr 2012
Article Copyright 2012 by Vivek_Sharma
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid