ASP.NET Ajax Control (TextBoxWatermarkExtender,ValidatorCalloutExtender)

article about ASP.NET Ajax Control TextBoxWatermarkExtender,ValidatorCalloutExtender)

Here I demonstrate how to use AJAX Control TextBoxWatermarkExtender and ValidatorCalloutExtender in ASP.NET.

<asp:TextBox ID="txtFname" runat="server"/>
<asp:RequiredFieldValidator ID="rfvFname" runat="server" ErrorMessage="Enter First Name"
ControlToValidate="txtFname" Display="None" ValidationGroup="vgCheck"/>
<ajaxToolkit:TextBoxWatermarkExtender ID="twFname" runat="server" TargetControlID="txtFname"
WatermarkText="Enter First Name"/>
<ajaxToolkit:ValidatorCalloutExtender ID="vcFname" runat="server" TargetControlID="rfvFname"/>
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" ValidationGroup="vgCheck" />

TextBoxWatermarkExtender : This Ajax control attached to Textbox control to get WaterMark behavior. When Textbox control is empty it display Watermark text.To attach TextBoxWatermarkExtender to TextBox set TargetControlId of TextBoxWatermarkExtender to particular TextBox.

Here,I set TargetControlID of twFname to txtFname and set WatermarkText for txtFname.
You can also use Css Class with watermark contol.

ValidatorCalloutExtender : This Ajax control enhances the functionality of existing ASP.NET validators. To use this control, add an input field and a validator control as you normally would. Then add the ValidatorCallout and set its TargetControlID property to reference the validator control.

Here, I use rfvFname RequiredFieldValidator control to validate txtFname TextBox control. To use ValidatorCalloutExtender I set TargetControlID to rfvFname RequiredFieldValidator.

So,both control TextBoxWatermarkExtender,ValidatorCalloutExtender ASP.NET AJAX Control is very easy to understand and use to it.


No responses found. Be the first to comment...