AdBlock Detected

We provide high-quality source code for free. Please consider disabling your AdBlocker to support our work.

Buy me a Coffee

Saved Tutorials

No saved posts yet.

Press Enter to see all results

How To Dynamically Add AJAX Control Toolkit ValidatorCallout Extender

By pushpam abhishek
Listen to this article

Dynamically Add AJAX Control Toolkit ValidatorCallout Extender in Asp.net

Hi, Today we will learn about adding Ajax Control ToolKit ValidatorCallout. we can find the  Ajax Control ToolKit ValidatorCallout control in ajax controls list from Toolbox in asp.net.

Dynamically Add AJAX Control Toolkit ValidatorCallout Extender in Asp.net

Here we tack an example add Ajax Control ToolKit ValidatorCallout in asp.net. we will display current time and date on web forms in asp.net.To add Ajax Control ToolKit ValidatorCallout we need one TextBox and RequiredFieldValidator. 
Now I am creating all controls that are adding dynamically.  For more information, see  ValidatorCallout control.

first, we design the asp.net web forms like below:


 using System; 
 using System.Collections.Generic;
 using System.Linq; using System.Web; 
 using System.Web.UI; 
 using System.Web.UI.WebControls;
  using System.Data;
   public partial class Default2 : System.Web.UI.Page 
   {     protected void Page_Load(object sender, EventArgs e)  
      {       
            //Dynamically Creating TextBox       
              TextBox txtBox = new TextBox();         
              txtBox.ID = "TextBox1";         
              txtBox.MaxLength = 100;          
          //Dynamically Creating RequiredFieldValidator Control        
          RequiredFieldValidator requiredFieldValidater = new RequiredFieldValidator();        
          requiredFieldValidater.ID = "RequiredFieldValidator1";       
          requiredFieldValidater.ControlToValidate = txtBox.ID;        
           requiredFieldValidater.ErrorMessage = "Name is required.";      
              requiredFieldValidater.Text = "*";          
      //Dynamically Creating ValidatorCalloutExtender Control        
            AjaxControlToolkit.ValidatorCalloutExtender validatorCalloutExtender = new AjaxControlToolkit.ValidatorCalloutExtender();   
            validatorCalloutExtender.ID = "ValidatorCalloutExtender1";        
             validatorCalloutExtender.TargetControlID = requiredFieldValidater.ID;        
        //Dynamically Adding controls to PlaceHolder Control      
           PlaceHolder1.Controls.Add(txtBox);       
          PlaceHolder1.Controls.Add(requiredFieldValidater);     
              PlaceHolder1.Controls.Add(validatorCalloutExtender);    
               } 
               }  
////////////////
//Design Page … Save it as timer.aspx
//////////////////

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ 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>
<form id="form1" runat="server">
</head> <body>
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
</div> </form> </body> </html>
 

Share this post

pushpam abhishek

About pushpam abhishek

Pushpam Abhishek is a Software & web developer and designer who specializes in back-end as well as front-end development. If you'd like to connect with him, follow him on Twitter as @pushpambhshk

Comments