dynamically adding validator controls

G

Guest

Hi there,

I'm trying to add validator controls dynamically and it's not working. The
code is below.....thanks in advance for any answers.
The control doesn't appear to be showing up in the page.


override protected void OnInit(EventArgs e)
{

RangeValidator r = new RangeValidator();
r.ErrorMessage = m.ErrorText.ToString();
r.ControlToValidate = "tbxAgencyPhone";
r.MinimumValue="2";
r.MaximumValue="3";
r.EnableClientScript=true;
r.Visible=true;
r.Enabled=true;
r.EnableViewState=true;
this.Validators.Add(r);
this.Form1.Controls.Add(r);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top