Posted by : Anwar Hossain
Category : How to use ajax toolkit in asp.net C#

How to use TextBoxWatermarkExtender in asp.net using c#

Dear viewers I will show how to use TextBoxWatermarkExtender in asp.net c#. TextBoxWatermark Extender can be attached with ASP.NET TextBox control to display "watermark" style .When watermarkTextBox is empty it can be displayed a message to enter something to viewers. In this case at first I have created a css for text to show as watermark style .Then I have taken necessary textboxs and added TextBoxWatermarkExtender to the textboxs. Three properties has been used such as TargetControlId of TextBoxWatermarkExtender to particular TextBox , WatermarkText for writing text and WatermarkCssClass for assigning css .

TextBoxWatermarkExtender in ASP.NET C#

HTML

<%@ Register Assembly="AjaxControlToolkit" Namespace="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>
  <style type="text/css">
  .waterMarkcss
  {
  color: Gray;
  }
  </style>
</head>
<body>
  <form id="form1" runat="server">
  <div>
  <table cellpadding="2" cellspacing="5" style="width: 100%">
  <tr>
  <td>
  <asp:TextBox ID="txtName" runat="server" Width="200px"></asp:TextBox>
  <asp:TextBoxWatermarkExtender ID="txtName_TextBoxWatermarkExtender" runat="server"
  Enabled="True" TargetControlID="txtName" WatermarkText="Enter Your Name" WatermarkCssClass="waterMarkcss">
  </asp:TextBoxWatermarkExtender>
  </td>
  </tr>
  <tr>
  <td>
  <asp:TextBox ID="txtSubject" runat="server" Width="200px"></asp:TextBox>
  <asp:TextBoxWatermarkExtender ID="txtSubject_TextBoxWatermarkExtender" runat="server"
  Enabled="True" TargetControlID="txtSubject" WatermarkText="Enter Subject " WatermarkCssClass="waterMarkcss">
  </asp:TextBoxWatermarkExtender>
  </td>
  </tr>
  <tr>
  <td>
  <asp:TextBox ID="txtEmail" runat="server" Width="400px"></asp:TextBox>
  <asp:TextBoxWatermarkExtender ID="txtEmail_TextBoxWatermarkExtender" runat="server"
  Enabled="True" TargetControlID="txtEmail" WatermarkText="Enter Your Email" WatermarkCssClass="waterMarkcss">
  </asp:TextBoxWatermarkExtender>
  </td>
  </tr>
  <tr>
  <td>
  <asp:TextBox ID="txtInquiry" runat="server" Height="100px" TextMode="MultiLine" Width="400px"></asp:TextBox>
  <asp:TextBoxWatermarkExtender ID="txtInquiry_TextBoxWatermarkExtender" runat="server"
  Enabled="True" TargetControlID="txtInquiry" WatermarkText="Enter Your Inquiry"
  WatermarkCssClass="waterMarkcss">
  </asp:TextBoxWatermarkExtender>
  </td>
  </tr>
  <tr>
  <td>
  <asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
  </td>
  </tr>
  <tr>
  <td>
  <asp:Button ID="btnSubmit" runat="server" Text="Send" Width="100px" />
  </td>
  </tr>
  <tr>
  <td>
  &nbsp;
  <asp:ScriptManager ID="ScriptManager1" runat="server">
  </asp:ScriptManager>
  </td>
  </tr>
  </table>
  </div>
  </form>
</body>
</html>

Out Put

asp.net c # water mark example



Realted Article Headline

How to use TextBoxWatermarkExtender in asp.net using c#
How to use Ajax AutoCompleteExtender control in asp.net using c#
How to use Ajax Collapsible panel control in asp.net c#
How to use ASP.Net AJAX Control Toolkit ModalPopupExtender Control in asp.net c#
how to add an Ajax Control Toolkit Accordion to a page
How to use html editor Ajax control toolkit example in c#
How to use Ajax ConfirmButtonExtender in asp.net using c#
how to use ajax calendar extender in asp net c#
How to use ajax toolkit FilteredTextBox Control in c#

Article Category

How to create asp.net control dynamically
Learn HTML for beginner
DataList example in C Sharp
Mail sending in asp.net c#
State Management in ASP C #
Basic sql tutorial for Beginner
DataTable example in ASP.Net C#
How to use LINQ in ASP.NET C#
asp.net c # basic tutorial
How to use ajax toolkit in asp.net C#
How to use different types of validation control using asp.net c#
How to use grid view in asp.net c#
Protected by Copyscape Online Plagiarism Detection