|
-
Oct 26th, 2009, 05:28 AM
#1
Thread Starter
Addicted Member
problem with radio button in asp.net
Hi all,
I have an issue with radiobuttonlist in asp.net.
Under selectedindexchanged event of radiobutton list, i'm doing marks calculation.
Actually speaking,that event should run only one time..but even after finishing the calculation, selectedindexchanged event is again loading so that my marks result is showing wrong..
Even i tried with page.ispostback condition also..no correct results came..
Plz help to do this..
Thanks in advance,
Priyajee
-
Oct 26th, 2009, 05:31 AM
#2
Re: problem with radio button in asp.net
Hey,
Can you show the code that you are using?
Does the RadioButtonList AutoPostBack to the server, or do you have a Submit Button?
Gary
-
Oct 26th, 2009, 11:07 AM
#3
Thread Starter
Addicted Member
Re: problem with radio button in asp.net
Code:
Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonListQ1.SelectedIndexChanged
If RadioButtonListQ1.SelectedItem.Value = "radQ1a" Then
Session("marks") = 1
Else
Session("noofwronganswers") = 1
End If
End Sub
Protected Sub RadioButtonListQ2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButtonListQ2.SelectedIndexChanged
If RadioButtonListQ2.SelectedItem.Value = "radQ2b" Then
Session("marks") = Session("marks") + 1
Else
Session("noofwronganswers") = Session("noofwronganswers") + 1
End If
End Sub
Protected Sub cmdFinishtest_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdFinishtest.Click
lblmarksscroed.Text = "Marks Scored:" & Session("marks")
lblnoofwrong.Text = "No.of Wrong Answers:" & Session("noofwronganswers")
End Sub
Hai this is my code..
Thanks,
Priyajee
-
Oct 26th, 2009, 11:28 AM
#4
Hyperactive Member
Re: problem with radio button in asp.net
 Originally Posted by priyajee
Hi all,
I have an issue with radiobuttonlist in asp.net.
Under selectedindexchanged event of radiobutton list, i'm doing marks calculation.
Actually speaking,that event should run only one time..but even after finishing the calculation, selectedindexchanged event is again loading so that my marks result is showing wrong..
Even i tried with page.ispostback condition also..no correct results came..
Plz help to do this..
Thanks in advance,
Priyajee
looks like you are setting up a test...
instead of using session, you can use arraylist..(static) saving server resources..
if answer is correct add 1 to array list./..
on submit button calculate sum up all the 1's..
and get the output..
-------------------------------------------------------------------
in your code i guess you need to typecast the value of session..
in order to get the sum...
hope that helps..
-
Oct 26th, 2009, 01:05 PM
#5
Re: problem with radio button in asp.net
Hey,
You still haven't really answered the question.
Is your RadioButtonList configured to post back to the server each time? If not, you have to take into consideration that ASP.Net will "remember" each change to the RadioList, and when you eventually post back to the server, it will do each SelectedChanged Event.
Can you define exactly what you want to achieve, perhaps with the aid of screen shots, and I am sure that we will be able to help you.
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|