<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Anotherwayofwatermark.aspx.cs" Inherits="Anotherwayofwatermark" %>

<!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></title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type = "text/javascript">
        var defaultText = "UserName";
        

        function WaterMark(txt, evt) {

            if (txt.value.length == 0 && evt.type == "blur") {
                txt.style.color = "gray";
                txt.value = defaultText;
            }
            if (txt.value == defaultText && evt.type == "focus") {
                txt.style.color = "black";
                txt.value = "";
            }




        }

        
</script> 



</head>
<body>
    <form id="form1" runat="server">
   <div>This demonstration shows how we can we set the watermark in the textbox</div>
    <div style="border-radius:6px;margin-left:200px;background-color:Gray; width:160px; padding-top:20px; padding-bottom:20px; padding-left:10px; padding-right:15px;">
        <asp:TextBox ID="TextBox1" runat="server" Text = "UserName"  ForeColor = "Gray" onblur = "WaterMark(this, event);" onfocus = "WaterMark(this, event);"></asp:TextBox>
    </div>
    </form>
</body>
</html>
