Dinamic control validation

G

Guest

I have to make a survey and I have te following problem.

For each question in a subject (our survey had multiple subjects) I add a
radiobuttonlist and a requerdvieldvalidator to te control collection. After
the page is posted back the result is saved and the control collection is
cleard and filled with a new subject. Now when the page is loaded all the
validators are showing up even before any input is given. It feels like
onload validation but I cant't find a thing on that and have no clue how to
stop the validator to show up on second pageload.

Anyone ideas about that?
 
R

Rob Meade

...
For each question in a subject (our survey had multiple subjects) I add a
radiobuttonlist and a requerdvieldvalidator to te control collection.
After
the page is posted back the result is saved and the control collection is
cleard and filled with a new subject. Now when the page is loaded all the
validators are showing up even before any input is given. It feels like
onload validation but I cant't find a thing on that and have no clue how
to
stop the validator to show up on second pageload.

Its doing what is supposed to according to your description - you've
returned to the page, after posting, but you've cleared all the values, so
that validators are saying "ok - we've posted, and look at all these fields
that haven't been selected"..

Not sure if it'll work, but you could try setting the "InitialValue" on each
of the validators, for example,if you have drop down lists, and the first
item is "Please Select" with a value of 0 (zero) - then set the initial
value on the validator as 0 (zero) - see if that helps - when you reload
your page and have cleared all of your controls, I'm assuming that you
repopulate with these values?

Rob
 
G

Guest

What a do is not clearing anything I just remove all controls and add new
ones, with divrend id's .

The sultution I figured out is this:

Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter)
For Each v As IValidator In Me.Page.Validators
v.IsValid = True
Next
MyBase.Render(writer)
End Sub

It's not the niced way but it's working


Regards Pieter
 
R

Rob Meade

...
What a do is not clearing anything I just remove all controls and add new
ones, with divrend id's .

I see, maybe it still has the values of the previous controls in the
viewstate then?

Glad you've got a solution anyway :eek:)

Rob
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top