Dynamic AJAX Control Toolkit – ValidatorCallout Extender

July 24, 2008 • Damien White

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;

Posted in .net, ajax control toolkit, asp.net and tagged with AJAX, ASP.NET, ASP.NET AJAX

Damien White

I am a software architect with over 16 years of experience. I simply love coding! I have a driving passion for computers and software development, and a thirst for knowledge that just cannot be quenched. I'm happy to share what I know in my quest to learn as much as possible. I focus most of my time on web development using Ruby on Rails, Ember.js, and ASP.NET MVC.

comments powered by Disqus