ValidatorCalloutExtender In Ajax

ValidatorCalloutExtender:
ValidatorCalloutExtender is an ASP.NET AJAX extender that 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 ValidatorCalloutExtender and set its TargetControlID property to reference the validator control.
ValidatorCalloutExtender Properties:-
1. TargetControlID :- The ID of the Validator to extend
2. Width :- The width of the callout
3. CssClass :- Name of the CSS class used to style the ValidatorCallout.
4. HighlightCssClass: - A CssClass to apply to the invalid field
5. WarningIconImageUrl :- The path to a custom warning icon image

6. CloseImageUrl :- The path to a custom close image
7. PopupPosition: – Indicates where the ValidatorCallout popup should appear at the BottomLeft,    BottomRight, TopLeft, TopRight, Left or Right (default) of the control to validate.
8. Animations: - Generic animations for the ValidatorCallout extender. See the Using Animations walkthrough and Animation Reference for more details.
9. OnShow: - The OnShow animation will be played each time the validation popup is displayed. The popup will be positioned correctly but hidden. The animation can use to display the popup along with any other visual effects.
10. OnHide: - The OnHide animation will be played each time the validation popup is hidden.

Ex:-
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidatorCalloutExtender.aspx.cs" Inherits="ValidatorCalloutExtender" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server"> <title></title> </head>
 <body>
<form id="form1" runat="server">
 <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager> <div>
 <h3>Ajax Control Toolkit Example: Using ValidatorCalloutExtender</h3>
 <hr />
 <b>Enter Name: </b>
 <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtName" ErrorMessage="Please Enter Your Name" ForeColor="Red" Display="None"></asp:RequiredFieldValidator>
<asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1"> </asp:ValidatorCalloutExtender> <br /> <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" /> <br /> <asp:Label ID="lblStatus" runat="server"></asp:Label>
 </div>

Code-View:-

protected void btnSubmit_Click(object sender, EventArgs e)
{
 lblStatus.Text = "Your Name Is: " + txtName.Text.Trim();
}

Output:-




No comments:

Post a Comment