0

I have two radio buttons that will determine the min value of the range validator of a textbox. So the radio buttons work well (resetting the min value on every CheckedChanged), except when the textbox display error message like "enter min value xxx", then the radio button has to be clicked twice (which is buggy) only it will trigger the vb code. Can someone help me with this? Thank you!

The code for RadioButtons:

<asp:RadioButton runat="server" ID="rbSameT" Text="SameT" GroupName="rbGroupT" Checked="true" AutoPostBack="true" OnCheckedChanged="rbSameT_CheckedChanged"/>
<asp:RadioButton runat="server" ID="rbDiffT" Text="DiffT" GroupName="rbGroupT" AutoPostBack="true" OnCheckedChanged="rbDiffT_CheckedChanged"/>
            

The code behind for the RadioButtons:

Protected Sub rbSameT_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rbSameT.CheckedChanged
    If sender IsNot Nothing And e IsNot Nothing Then
        ResetValidators(False)
    End If
End Sub

Protected Sub rbDiffT_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles rbDiffT.CheckedChanged
    ResetValidators(True)
End Sub
z-yee
  • 1
  • 1
  • You may use an integer variable which is incremented every time the radio button is clicked to check the count.Once it's clicked twice, the variable value can be reset. – Utkarsh Dec 02 '20 at 04:55
  • @Utkarsh the variable value suppose to reset on checked changed. Not when it's clicked twice. I'll edit my post to clarify on this. – z-yee Dec 02 '20 at 05:06

1 Answers1

0

Try removing the Checked="true" and set EnableViewState="True"

<asp:RadioButton runat="server" ID="rbSameT" Text="SameT" GroupName="rbGroupT" 
 AutoPostBack="true" OnCheckedChanged="rbSameT_CheckedChanged" EnableViewState="True"/>

<asp:RadioButton runat="server" ID="rbDiffT" Text="DiffT" GroupName="rbGroupT" 
 AutoPostBack="true" OnCheckedChanged="rbDiffT_CheckedChanged" EnableViewState="True"/>
        
Vignesh Kumar A
  • 27,863
  • 13
  • 63
  • 115