vijay

welcome Netizen

Share Your Knowledge.It is a way to achieve immortality

Monday, January 2, 2012

TextBoxWatermarkExtender in AjaxControlToolkit or watermark textbox using asp.net


Hi

Introduction:

Last articles I wrote about apply watermark text using javascript.For your refrence below I mention path.


Now here using ajax control kit you can apply easily watermark text in textbox.

Description:

Intially you have to use ajax control dll file to add TextBoxWatermarkExtender, then drag the control and set watertext,targetcontrolid in the extender.

Sample code as shown below………

    <div>
        <asp:TextBox ID="txt1" runat="server"></asp:TextBox>&nbsp;&nbsp;
        <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" TargetControlID ="txt1" WatermarkText ="Name" WatermarkCssClass ="txt">
        </asp:TextBoxWatermarkExtender>
        <asp:TextBox ID="txt2" runat="server"></asp:TextBox>&nbsp;&nbsp;
                <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server" TargetControlID ="txt2" WatermarkText ="Address" WatermarkCssClass ="txt">
        </asp:TextBoxWatermarkExtender>

        <asp:TextBox ID="txt3" runat="server"></asp:TextBox>&nbsp;&nbsp;
        <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender3" runat="server" TargetControlID ="txt3" WatermarkText ="DOB" WatermarkCssClass ="txt">
        </asp:TextBoxWatermarkExtender>


    </div>

 

<style type ="text/css" >
    .txt
    {
   
    color:Gray;
   
    }
</style>

Properties:

·         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).

I hope you find something useful today……

0 comments:

Post a Comment