R4R
Right Place For Right Person TM
R4R AJAX with C# AJAX  Tutorials TextBoxWatermark Control
previous

Home

Next

TextBoxWatermark Control

  1. This Control attached to an ASP.NET TextBox control to get "watermark" behavior on the web Page.
  2. Purpose of this control to provide more information to user.

Properties

  1. TargetControlID, Control ID.
  2. WatermarkText, The text to show when the control has no value
  3. WatermarkCssClass,  The CSS class to apply to the TextBox.
     

Step.1 Drag ScriptManager Control and add a two Text Box . Click on First Text Box and click on Add Extender.

 

Step 2. Above process is repeat for the Second Text Box (Same as above). Add a button and Two Label on page for show the text which user enter in Text Box. Paste the Below code on button Click (Default.aspx.cs).


protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "Hello!!!!" + "" +TextBox1.Text.ToString();
        Label2.Text = "" + TextBox2.Text.ToString();
    }

The Design Code (Default.aspx)


<%@ Page Language="C#" AutoEventWireup="true"  Codevirtual="Default.aspx.cs"
 Inherits="_Default" %>
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .style2
        {
            width: 100%;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server" 
        style="top: 86px; left: 10px; position: absolute; height: 22px; 
        width:223px"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" 
        style="top: 138px; left: 9px; position: absolute; height: 21px;
         width: 225px"></asp:TextBox>
    <cc1:TextBoxWatermarkExtender ID="TextBox2_TextBoxWatermarkExtender" 
        runat="server" Enabled="True" TargetControlID="TextBox2"
         WatermarkText="Enter Your Second Name..">
    </cc1:TextBoxWatermarkExtender>
    <asp:Button ID="Button1" runat="server" 
        style="top: 134px; left: 294px; position: absolute; height: 26px; 
        width: 56px" 
        Text="Submit" onclick="Button1_Click" />
        </div>  
          <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <asp:Label ID="Label1" runat="server"></asp:Label>
    <asp:Label ID="Label2" runat="server"></asp:Label>
          </form>
</body>
</html>

 

Step 3. Debug the Application. Output Will Be

Enter text in Textbox

previous

Home

Next


Tolal:0 Click:
Show All Comments

Post Your Comments

Your Name:

Your Email ID :
Comments :
URL
  =* Enter SUM

New Updates

R4R
R4R
R4R
R4R
R4R
R4R
R4R
R4R