I added one of these a while ago and figured I would include another. Dynamic AJAX Toolkit Controls seem to really be an issue for some, so I hope this helps. This time, we will create a dynamic ValidatorCallout for a TextBox with a RequiredFieldValidator (although you can use any validation method). One other thing to note on the ValidatorCallout is that it only works with client-side validation.
TextBox nameTextbox = new TextBox(); nameTextbox.ID = "name"; nameTextbox.MaxLength = 100; RequiredFieldValidator nameRequired = new RequiredFieldValidator(); nameRequired.ID = "nameRequired"; nameRequired.ControlToValidate = nameTextbox.ID; nameRequired.ErrorMessage = "Name is required."; nameRequired.Text = "*"; ValidatorCalloutExtender nameRequiredCallout = new ValidatorCalloutExtender(); nameRequiredCallout.ID = "nameRequiredCallout"; nameRequiredCallout.TargetControlID = nameRequired.ID;