Results 1 to 5 of 5

Thread: problem with radio button in asp.net

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    144

    Question 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

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2007
    Posts
    144

    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

  4. #4
    Hyperactive Member dnanetwork's Avatar
    Join Date
    Oct 2007
    Location
    Mumbai
    Posts
    349

    Thumbs up Re: problem with radio button in asp.net

    Quote Originally Posted by priyajee View Post
    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..

  5. #5
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    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
  •  



Click Here to Expand Forum to Full Width