Dynamically generating control validators

C

-=Chris=-

I'm developing a custom server control that will be rendering a form based
on some input. I've tried creating custom validators in vb.net like so:

Dim v1 as RequiredValidator = new RequiredValidator()
Dim vs as ValidationSummary = new ValidationSummary()

RequiredValidator.ControlToValidate = "id of form control here"
RequiredValidator.Enabled = True
RequiredValidator.EnableClientScript = True
RequiredValidator.ErrorMessage = "Test message"

ValidationSummary.ShowSummary = False
ValidationSummary.ShowMessageBox = True
ValidationSummary.EnableClientScript = True
ValidationSummary.Enabled = True


Now when I submit the form, I have a piece of code in the button's onclick
event that does:

Response.Write "Page Validity: " & Me.IsValid

When the fields are not filled in properly, me.IsValid returns false as
expected, but the ValidationSummary never displays the messagebox. It's
almost like the validation controls have to be registered with the
validation summary somehow, and that's not happening.

Any ideas? What am I missing?


Thanks in advance,
Chris
 
B

bill

How about
Page.Controls.Add( vs );

-=Chris=- said:
I'm developing a custom server control that will be rendering a form based
on some input. I've tried creating custom validators in vb.net like so:

Dim v1 as RequiredValidator = new RequiredValidator()
Dim vs as ValidationSummary = new ValidationSummary()

RequiredValidator.ControlToValidate = "id of form control here"
RequiredValidator.Enabled = True
RequiredValidator.EnableClientScript = True
RequiredValidator.ErrorMessage = "Test message"

ValidationSummary.ShowSummary = False
ValidationSummary.ShowMessageBox = True
ValidationSummary.EnableClientScript = True
ValidationSummary.Enabled = True


Now when I submit the form, I have a piece of code in the button's onclick
event that does:

Response.Write "Page Validity: " & Me.IsValid

When the fields are not filled in properly, me.IsValid returns false as
expected, but the ValidationSummary never displays the messagebox. It's
almost like the validation controls have to be registered with the
validation summary somehow, and that's not happening.

Any ideas? What am I missing?


Thanks in advance,
Chris
 
C

-=Chris=-

No dice. I even tried adding the summary control through the IDE using
drag/drop to make sure it was registered. Still no message.

I was minding my own business when bill blurted out:
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top