Solved

Submit event causes IE error with RadioButtonList validation

Posted on 2006-11-19
4
374 Views
Last Modified: 2008-01-09
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
0
Comment
Question by:donaldcroswell
  • 2
  • 2
4 Comments
 
LVL 12

Expert Comment

by:sandip132
ID: 17976582
What error you are getting ?
0
 

Author Comment

by:donaldcroswell
ID: 17976641
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
0
 
LVL 12

Accepted Solution

by:
sandip132 earned 500 total points
ID: 17976659
This seems problem with your IE/Or other application. You could try to remove and reinstall IE or the application in whose exe the error is occuring.

If IE is working fine. try using Panel control instead of SPAN.

I have tested same application on my PC with Panel control... works fine.

HTML:
<asp:radiobuttonlist id="RadioButtonList1" style="Z-INDEX: 101; LEFT: 272px; POSITION: absolute; TOP: 64px"
                              runat="server" AutoPostBack="True">
                              <asp:ListItem Value="Op1">Op1</asp:ListItem>
                              <asp:ListItem Value="Op2">Op2</asp:ListItem>
                              <asp:ListItem Value="Op3">Op3</asp:ListItem>
                              <asp:ListItem Value="Others">Others</asp:ListItem>
                        </asp:radiobuttonlist>
<asp:Panel id="Panel1" style="Z-INDEX: 102; LEFT: 360px; POSITION: absolute; TOP: 136px" runat="server"
                              Height="32px" Width="296px" visible="False">Please Specify
<asp:TextBox id="txt2Other" runat="server"></asp:TextBox></asp:Panel>

And the code behind:

    Private Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButtonList1.SelectedIndexChanged
        If RadioButtonList1.SelectedValue = "Others" Then
            Panel1.Visible = True
        Else
            Panel1.Visible = False
        End If
    End Sub

0
 

Author Comment

by:donaldcroswell
ID: 17976672
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
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now