Link to home
Start Free TrialLog in
Avatar of donaldcroswell
donaldcroswell

asked on

Submit event causes IE error with RadioButtonList validation

Hello All

I have a submit_button on a form with multiple RadioButtonList Validations like below.

<asp:RadioButtonList ID="radio2" runat="server" AutoPostBack="True" OnSelectedIndexChanged="showOther">
    <asp:ListItem Text="Word of mouth" Value="Word of mouth" />
    <asp:ListItem Text="Internet search" Value="Internet search" />
    <asp:ListItem Text="Advertising" Value="Advertising" />
    <asp:ListItem Text="TSEAP leaflet" Value="TSEAP leaflet" />
    <asp:ListItem Text="Other" Value="Other"/>
    </asp:RadioButtonList>
    <span id="span2" runat="server" visible="false">(please specify) <asp:TextBox runat="server" ID="txt2Other" /></span>
    <asp:RequiredFieldValidator ControlToValidate="radio2" ID="val2" runat="server" ErrorMessage="*Required" SetFocusOnError="true" />

It just calls a script on postback and shows the "span" tag if the "Other" radio is selected.

when I test the page and click the submit_form button it will highlight all the radiobutton groups that were not filled in. (GREAT!)

then, if I click on a radio button group that has a "OnSelectedIndexChanged" function, (like the one above) it will turn off ALL of the red validation text on ALL the groups and cause an error when the form is submitted without "ALL" of the groups checked.

I think something is happening in my showOther() function that is called on postback which turns all of my errors off:

    Protected Sub showOther(ByVal sender As Object, ByVal e As System.EventArgs)
        If radio2.SelectedValue = "Other" Then
            span2.Visible = True
        Else
            span2.Visible = False
        End If
    End Sub

Any ideas as to why the validation generates an error instead of flagging the radio groups that still don't have a selection?

Many thanks in advance.

Cheers
Don
Avatar of sandip132
sandip132
Flag of Japan image

What error you are getting ?
Avatar of donaldcroswell
donaldcroswell

ASKER

Hi Sandip

First I get the:
Internet Explorer has encountered a problem and needs to close.  We are sorry for the inconvenience.


Then I get:
The instruction at "0x7470b439" referenced memory at "". The memory could not be "read".
Click on OK to terminate the program

Thanks
Don
ASKER CERTIFIED SOLUTION
Avatar of sandip132
sandip132
Flag of Japan image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hey

That saved me lots of time!

I would have never thought of that and don't understand really why it works now but your help is very much appreciated.

Cheers
Don