Add WaterMark to TextBox (TextBoxWatermarkExtender)

Posted: October 7, 2010 in AJAX, ASP.Net

When trying to add a WaterMark to a TextBox control, you can try the following using the Ajax Control Toolkit:

<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>WaterMark Extender</title>
</head>
<body>
    <form id="frm_main" runat="server">
        <asp:ScriptManager ID="scr_main" runat="server" />
        <asp:UpdatePanel ID="ajax_upd_pnl_main" runat="server">
            <ContentTemplate>
                <div id="div_main">
                    <asp:TextBox ID="txt_year" runat="server"></asp:TextBox></div>
                    <cc1:TextBoxWatermarkExtender ID="wme_txt_year" runat="server" TargetControlID="txt_year" WatermarkText="(year)"></cc1:TextBoxWatermarkExtender>          
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s