show-notice
hide-notice

Thursday, 4 July 2013

How to use TextBoxWatermarkExtender in asp.net ajax




Introduction: 

TextBoxWatermark is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to get "watermark" behavior. When a watermarked TextBox is empty, it displays a message to the user with a custom CSS style.


Description:

Once the user has typed some text into the TextBox, the watermarked appearance goes away. The typical purpose of a watermark is to provide more information to the user about the TextBox itself without cluttering up the rest of the page.






<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server"> 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            Label1.Text = "Subscription Successful!"; 
        } 
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Ajax TextBoxWatermarkExtender - How to use TextBoxWatermarkExtender in asp.net
        ajax</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color: DarkBlue; font-style: italic;">
            Ajax Control Toolkit Example: Using TextBoxWatermarkExtender</h2>
        <hr width="550" align="left" color="LightBlue" />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:TextBoxWatermarkExtender ID="TexBoxWatermarkExtender1" runat="server" TargetControlID="TextBox1"
            WatermarkText="Input your email">
        </cc1:TextBoxWatermarkExtender>
        <br />
        <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Bold="true" Font-Size="Large"> 
        </asp:Label>
        <br />
        <br />
        <asp:TextBox ID="TextBox1" runat="server" ForeColor="SeaGreen"> 
        </asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Subscribe RSS Feed" OnClick="Button1_Click"
            Height="30" Font-Bold="true" ForeColor="Green" />
    </div>
    </form>
</body>
</html>








SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com