You must Sign In to post a response.
  • Category: ASP.NET

    How to show watermark in textbox ?

    Are you looking for a way to show watermark in textbox ? then read this thread to know how to do it

    I have two textbox viz textbox1 and textbox2.
    I want to show watermark in that textboxes.

    When i will write in one textbox, second textbox will show watermark text.
    So when i will go to second textbox the first textbox should get clear and should show water mark text.

    So how can i do that.

    Please help.

    Thanks in Advance.
  • #724727
    check the ajax toolkid textbox water mark

    here you can find how you can set the water mark properties to textbox

    hopes this will help you

  • #724728
    [Response removed by Admin. Read forum policies.]
    Rakesh Chaubey

  • #724731
    So basically you want to type a character as watermark in one and other textbox.
    Javascript will help you to accomplish the task

    //when you type in textbox1 call following javascript function
    //to create a water mark effect make textbox backcolor to lightgray
    function autoTextBox2()
    //change the backcolor of textbox 2
    document.getElementById("TextBox2").style.backgroundColor = "lightgrey";
    //set textbox1 color to textbox 2
    document.getElementById("TextBox2").Value = document.getElementById("TextBox1").Value;
    //make return false to avoid the postback
    return false;

    //call above function on 'onkeypress' event of textbox1
    <asp:TextBox id="TextBox1" runat="server" onkeypress="return autoTextBox2()" />

    Hope it helps

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #724742

    try to use ajax watermark like below code

    <asp:ToolkitScriptManager ID="ToolkitScriptManager2" runat="server">
    <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" WatermarkText="Enter your name here !"
    Enter Your Name :<asp:TextBox ID="txtName" runat="server"></asp:TextBox><br />

    Your Hard work never fails

  • #724782

    Usign AjaxWaterMarkextender you can achieve this. Download Ajax toolkit and add assembly reference for that and call that functionality in below manner.

    <%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

    Use below sample code

    /*Textbox Watermark*/

    height: 15px;
    width: 150px;

    height: 15px;
    width: 150px;
    padding: 2px 0 0 2px;
    border: 1px solid #BEBEBE;
    background-color: #F0F8FF;
    color: gray;

    and in your source code call that css classes in the below manner.

    <ajaxtoolkit:textboxwatermarkextender id="TBWE2" runat="server" targetcontrolid="txtMaterialAdd"
    watermarktext="Add Material" watermarkcssclass="watermarked" />
    <asp:TextBox ID="txtMaterialAdd" runat="server" Visible="false" CssClass="unwatermarked"

    You just use in below manner.
    Hope this information is helpful to you...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.