connectseekers.com

Sunday, 17 August 2014

Display Validation in ToolTip Using ValidatorCalloutExtender in Asp.Net

8/17/2014 - By Pranav Singh 0

This will show you how you  can use ValidatorCalloutExtender to validate textbox control and displaying the error message in tool tip. In this article I have used TextBox, RequiredFieldValidator, ValidatorCalloutExtender, RegularExpressionValidator.


So for this article first we will create new asp.net application and add the below html tag into your page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AjaxValidationByToolTip.aspx.cs"
    Inherits="ProjectDemo_Asp.et.AjaxValidationByToolTip" %>

<%@ 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>Display Validation in ToolTip Using ValidatorCalloutExtender in Asp.Net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <table width="300px">
            <tr>
                <td align="right">
                    Name :
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Please enter name."
                        Style="color: #FF0000" ControlToValidate="TextBox1" Display="None">*</asp:RequiredFieldValidator>
                        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1">
                        </asp:ValidatorCalloutExtender>
                </td>
            </tr>
            <tr>
                <td align="right">
                    Email :
                </td>
                <td>
                    <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Please enter email id."
                        Style="color: #FF0000" ControlToValidate="TextBox2" Display="None">*</asp:RequiredFieldValidator>
                        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender2" runat="server"  TargetControlID="RequiredFieldValidator2">
                        </asp:ValidatorCalloutExtender>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
                        ControlToValidate="TextBox2" Display="None"
                        ErrorMessage="Please enter a valid email id." style="color: #FF0000">*</asp:RegularExpressionValidator>
                          <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender4" runat="server"  TargetControlID="RegularExpressionValidator1">
                        </asp:ValidatorCalloutExtender>
                </td>
            </tr>
            <tr>
                <td align="right">
                    Address :
                </td>
                <td>
                    <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Please enter address."
                        Style="color: #FF0000" ControlToValidate="TextBox3" Display="None">*</asp:RequiredFieldValidator>
                        <asp:ValidatorCalloutExtender ID="ValidatorCalloutExtender3" runat="server"  TargetControlID="RequiredFieldValidator3">
                        </asp:ValidatorCalloutExtender>
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                     </td>
            </tr>
            <tr>
                <td align="right">
                     </td>
                <td>
                    <asp:Button ID="Button1" runat="server" Text="Submit" />
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

In above you have notices in RequiredFieldValidator I have set Display="None".


So why I have set this, if you not set this on that case with tool tip you will get the validation message also as shown below.


So we have done just run the page and check the output.

Now click on submit button  you will get the output.

About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

0 comments:

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com
Email Id : contact@aspdotnet-pools.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Top jQuery Plugins

Global Classified : Connectseekers.com
© 2014
back to top