show-notice
hide-notice

Thursday, 4 July 2013

How to use ValidatorCalloutExtender in asp.net ajax




Introduction: 

ValidatorCallout 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 ValidatorCallout and set its TargetControlID property to reference the validator control.


Description:

The callouts do not currently display automatically after a server post-back and will only work for custom validators which utilize client-side validation. Even after a post-back the callout will display when the form is re-validated when a postback is attempted again.







<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ 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">

<script runat="server"> 
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            Label1.Text = "You submitted name: " + TextBox1.Text; 
        } 
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Ajax ValidatorCalloutExtender - How to use ValidatorCalloutExtender in asp.net
        ajax</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color: Green; font-style: italic;">
            Ajax Control Toolkit Example: Using ValidatorCalloutExtender</h2>
        <hr width="575" align="left" color="LawnGreen" />
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1">
        </cc1:ValidatorCalloutExtender>
        <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large" Font-Names="Comic Sans MS"> 
        </asp:Label>
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Name" Font-Bold="true" ForeColor="DeepPink"> 
        </asp:Label>
        <asp:TextBox ID="TextBox1" runat="server"> 
        </asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
            ErrorMessage="Input your name!" Display="None"> 
        </asp:RequiredFieldValidator>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Submit Name" Height="40" Font-Bold="true"
            ForeColor="DeepPink" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>








SHARE THIS POST   

0 comments :

Post a Comment

Design by Gohilinfotech | www.gohilinfotech.blogspot.com