.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Post New Resource Bookmark and Share   

Water mark in text box in ASP.NET

Posted By:Ashutosh Jha       Posted Date: April 28, 2014    Points: 200    Category:    URL: http://www.dotnetspark.com  

Here i will show how we can use water mark in asp.net text box and when user clicks on it the water mark will get removed.
 

here i have used watermark.aspx as the name of the page. The whole page will look like the below-  

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="watermark.aspx.cs" Inherits="watermark" %>
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="asp" %>

<!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></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
    <div>
        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server" 
         TargetControlID="TextBox1" WatermarkText="Enter your name here !">
        </asp:TextBoxWatermarkExtender>
    </div>
    </form>
</body>
</html>


     

Further Readings:

Responses
Author: Ashutosh Jha         Company URL: http://www.dotnetspark.com
Posted Date: April 28, 2014

Sorry i missed the code. Here it is-

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="watermark.aspx.cs" Inherits="watermark" %>
<%@ Register Namespace="AjaxControlToolkit" Assembly="AjaxControlToolkit" tagPrefix="asp" %>

<!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></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<div>
<asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" runat="server"
TargetControlID="TextBox1" WatermarkText="Enter your name here !">
</asp:TextBoxWatermarkExtender>
</div>
</form>
</body>
</html>


Post Comment

You must Sign In To post reply
Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend