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



    Hi,
    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
    page
    http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/TextBoxWatermark/TextBoxWatermark.aspx

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

    hopes this will help you
    Thanks
    Swapnesh.P

  • #724728
    [Response removed by Admin. Read forum policies.]
    Regards
    Rakesh Chaubey
    rakeshchaubey1989@gmail.com

  • #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

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

  • #724742
    Hi,

    try to use ajax watermark like below code


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

    Regards
    N.Ravindran
    Your Hard work never fails

  • #724782
    Hi,

    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

    <style>
    /*Textbox Watermark*/

    .unwatermarked
    {
    height: 15px;
    width: 150px;
    }

    .watermarked
    {
    height: 15px;
    width: 150px;
    padding: 2px 0 0 2px;
    border: 1px solid #BEBEBE;
    background-color: #F0F8FF;
    color: gray;
    }
    </style>


    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"
    Width="100%"/>


    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.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • 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.