Hello Luke,
Thanks for the reply and yes fair comment. Below is a synopsis of the code.
One thing to note from your comment that I guess might be the cause of my
problem is that I NEVER remove the customValidator during a postback, I just
dont re-add it during a postback.
To clarify the situation, given the code below, here is what happens.
1) Initial call to OnInit(), dataConfidence is less than
field.Confidenc eThreshold, so ConfigureConfid enceLevelValida tion() is called
and the CustomValidator made and added to the scriptPlaceHold er (a
System.Web.UI.W ebControls.Plac eHolder). The customValidator appears correctly
oin the html.
2) After the "Apply" button is clicked the page is submitted and IsPostBack
== true. The call to UserCorrectedLo wConfidenceFiel d() returns true and
dataConfidence is set to 100. This means that dataConfidence is NOT less than
field.Confidenc eThreshold so ConfigureConfid enceLevelValida tion() is NOT
called but the validator still appears in the html when you view the source
on the newly generated page.
Thanks again for your post I appreciate your help.
Regards
Christian
-----------------------------------------------------
Basically the code looks like this:
OnInit()
{
....
.... // Various bit of unrelated code.
....
....
if (IsPostBack)
{
if (UserCorrectedL owConfidenceFie ld(field))
{
dataConfidence = 100;
}
dataValue = Request.Form[field.FieldName];
}
tb = AddTextBox(cell , field, dataValue);
if (dataConfidence < field.Confidenc eThreshold)
{
ConfigureConfid enceLevelValida tion(tb, field, dataConfidence) ;
}
....
.... // Various bit of unrelated code.
....
....
}
private void ConfigureConfid enceLevelValida tion(Control tb,
FormFieldsDS.Fo rmFieldsRow field, double dataConfidence)
{
CustomValidator cv = new CustomValidator ();
this.Validators .Add(cv);
scriptPlaceHold er.Controls.Add (cv);
cv.ControlToVal idate = tb.ID;
cv.ErrorMessage = string.Format(" {0}: field has a low confidence level.",
field.FieldName );
cv.Display = ValidatorDispla y.None;
cv.ClientValida tionFunction = "confidenceLeve lValidation";
}
"[MSFT]" wrote:
Hello,
Can you post some code to show how the CustomValidator are made and how one
of them are removed after postback? This may help us better undrstand the
problem and find what is going on there.
Regards,
Luke