Form being submitted when clicking on one of the radio buttons

I have a quiz--there is a question with radio buttons--basically what I am hoping to do is make filling in a text box required if a particular radio button is selected, however when a radio button is currently selected it is submitting the quiz.    it seems that there is something weird with AutoPostBack="true" from the code below.  I'd greatly appreciate any help with this--also, it seems that the code below currently isn't really working--because if I use the back arrow to return to the quiz after it is submitted and one of the radio buttons is selected (other than the one that if the user clicks on it they need to fill out a textbox), the validator is still coming up to fill in the text box.  

 <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">

void status_SelectedIndexChanged (object sender, System.EventArgs e)
	{
 
		if (status.SelectedItem.Text == "guest")
		{
			RequiredFieldValidator4.Enabled = true;
		}
		else
		{
			RequiredFieldValidator4.Enabled = false;
		}
	}
 
 
Status:*<br />														
  <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" AutoPostBack="true" runat="server">
			<asp:ListItem Value="undergraduate">
			</asp:ListItem>
			<asp:ListItem Value="graduate">
			</asp:ListItem>
			<asp:ListItem Value="fs">
			</asp:ListItem>
			<asp:ListItem Value="guest">
			</asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  <br /><br />

Open in new window

jianxin9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jens FiedererTest Developer/ValidatorCommented:
Something WEIRD?  "Submitting" is exactly what autopostback=true is SUPPOSED to do.

If you want to look at the value of thje radiobuttonlist after it is submitted by other means, don't set that.
0
jianxin9Author Commented:
Well  that's what I had figured, but someone from an earlier post said I needed to have that in there.  

This is what I am testing with now.  If anyone has any suggestions about how to get this to work, I would certainly appreciate them.  I do not want to submit anything--there is a submit button at the bottom of the form--I just want to make the text box required if the ListItem "guest" is selected.  Thanks!


void status_SelectedIndexChanged (object sender, System.EventArgs e)
	{
 
		if (status.SelectedItem.Text == "guest")
		{
			RequiredFieldValidator4.Enabled = true;
		}
		else
		{
			RequiredFieldValidator4.Enabled = false;
		}
	}
 	
 
Status:*<br />														
  <asp:RadioButtonList ID="status" OnSelectedIndexChanged="status_SelectedIndexChanged" runat="server">
			<asp:ListItem id="status_undergraduate" Text="undergraduate"></asp:ListItem>
			<asp:ListItem id="status_graduate" Text="graduate"></asp:ListItem>
			<asp:ListItem id="status_fs" Text="fs"></asp:ListItem>
			<asp:ListItem id="status_guest" Text="guest"></asp:ListItem>
		</asp:RadioButtonList>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="Server" ControlToValidate="status" ErrorMessage="Status" Text="*Status Required"></asp:RequiredFieldValidator><br />
		If you are a guest user,
		<br />
		please tell us what school are you from:<asp:TextBox ID="school" runat="server"></asp:TextBox>
		<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="Server" ControlToValidate="school" ErrorMessage="School Name" Text="*School Name Required"></asp:RequiredFieldValidator>
 
  <br /><br />

Open in new window

0
Jens FiedererTest Developer/ValidatorCommented:
This one is actually a bit tricky.

With ASP.NET, you kind of want to keep in mind what is on the client side and what is on the server side.

Your status_SelectedIndexChanged  is run on the server.  So it really has no effect UNTIL POSTBACK OCCURS.

Validation controls are capable of running client side as well as server side - so if your validation fails on the client side, NO POSTBACK OCCURS.

Oopss.....I see you are closing this!

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jianxin9Author Commented:
I did go ahead and repost since I am now trying something sightly different.  Thanks for the info though--I appreciate it.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.