Home All Groups Group Topic Archive Search About

Validator for checkbox is not getting triggered always

Author
7 Jan 2009 2:20 PM
shilpakalbhor
I have a validator class that extend baseValidator class applied to a
checkbox.In the validator class I have attached the javascript fuction called
AtleastOneChkBoxValidatorIsValid and in controlsTocheck I pass the name for
the checkbox in the group that need to validate as follows

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.
HtmlTextWriter)
        MyBase.AddAttributesToRender(writer)
        If Me.RenderUplevel
                    writer.AddAttribute("evaluationfunction",
"AtleastOneChkBoxValidatorIsValid")
                    writer.AddAttribute("controlstocheck", ControlsToCheck)

        End If
    End Sub

The problem I am facing is that whenever the validator gets firred the error
message is displayed but whenever I click a checkbox the error message should
go off but the error message is still displayed on the page it goes off after
I click 2nd or 3rd checkbox.the reason for this is that the method
AtleastOneChkBoxValidatorIsValid is not triggered always when a checkbox is
checked.

Author
10 Jan 2009 1:26 AM
Nathan Sokalski
Where are you getting the value for ControlsToCheck? You need to be sure to
use the GetControlRenderID method of the BaseValidator when determining the
value for ControlsToCheck. Do a View Source in your browser to make sure the
ID of the CheckBox is what you think it is. We may also be able to help you
more if you post your code as well. Good Luck!
--
Nathan Sokalski
njsokal***@hotmail.com
http://www.nathansokalski.com/

Show quoteHide quote
"shilpakalbhor" <u48653@uwe> wrote in message news:8fd4d3db5f803@uwe...
>I have a validator class that extend baseValidator class applied to a
> checkbox.In the validator class I have attached the javascript fuction
> called
> AtleastOneChkBoxValidatorIsValid and in controlsTocheck I pass the name
> for
> the checkbox in the group that need to validate as follows
>
> Protected Overrides Sub AddAttributesToRender(ByVal writer As
> System.Web.UI.
> HtmlTextWriter)
>        MyBase.AddAttributesToRender(writer)
>        If Me.RenderUplevel
>                    writer.AddAttribute("evaluationfunction",
> "AtleastOneChkBoxValidatorIsValid")
>                    writer.AddAttribute("controlstocheck", ControlsToCheck)
>
>        End If
>    End Sub
>
> The problem I am facing is that whenever the validator gets firred the
> error
> message is displayed but whenever I click a checkbox the error message
> should
> go off but the error message is still displayed on the page it goes off
> after
> I click 2nd or 3rd checkbox.the reason for this is that the method
> AtleastOneChkBoxValidatorIsValid is not triggered always when a checkbox
> is
> checked.
>