For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET > March 2007 > Re: Page Load is first then Radiobuttonlist.selecteditemChanged,









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Page Load is first then Radiobuttonlist.selecteditemChanged,
bruce barker

2007-03-29, 7:09 pm

move your page load code to prerender

-- bruce (sqlwork.com)

ricardo.sobral.santos@googlemail.com wrote:
> Hello,
>
> I am trying to get the value of the radiobuttonlist. The problem is
> that I need it to be unselected at every page load. The
> radiobuttonlist is set to autopostback (true).
> My idea is simple. When I select a value, I get it, insert something
> into the database with that value and the page loads again with
> different data. Imagine a questionnaire and every page load a random
> question would be load on screen and when the user clicks the
> radiobutton list, I get the value, insert into the database and only
> after I do the page_load again. Is there any way of doing this without
> a button, and setting the selecteditemchanged to fire first then the
> page_load?
>
> Tks for the help.
>
> The code is simple!
>
>
> 'My Page load is working just the way I want it!
> Protected Sub Page_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Me.Load
>
> If Not Page.IsPostBack Then
> RadioButtonList1.ClearSelection() ' I need it to be clear
> each time!
> leftPanel.Visible = False
> Dim users As New ArrayList
> users = User_.ArrayOfUsers
> Session.Add("users", users)
> Session.Add("i", 0)
>
> i = 0
> details = User_.getQuestions(users.Item(i))
> Image.ImageUrl = details(1).ToString
> lblLastChecked.Text = details(3).ToString
> details.Clear()
> 'users.Clear()
> Else
> 'RadioButtonList1.ClearSelection()
> i = CType(Session("i"), Integer)
>
> Dim users_tmp As ArrayList
> users_tmp = CType(Session("users"), ArrayList)
>
> If (i < users_tmp.Count - 1) Then
> detailsAfterRating =
> User_.getQuestions(users_tmp.Item(i))
> details = User_.getQuestions(users_tmp.Item((i + 1)))
>
> Image.ImageUrl = details(1).ToString
> lblLastChecked.Text = details(3).ToString
>
> RatedImage.ImageUrl = detailsAfterRating(2).ToString
> lblRating.Text = detailsAfterRating(5).ToString
> lblPastRate.Text = Session("youRated")
> i = (i + 1)
> Session.Add("i", i)
> 'details.Clear()
> 'detailsAfterRating.Clear()
> leftPanel.Visible = True
> Else
> Response.Redirect("Homepage.aspx")
> End If
>
>
> End If
> End Sub
>
>
>
>
>
>
>
> 'This works fine, but only after the page_load. So the first time is
> ok, but the second time I need it to be clear and to do something
> before it goes to page_load again.
>
> Protected Sub RadioButtonList1_SelectedIndexChanged(By
Val sender
> As System.Object, ByVal e As System.EventArgs) Handles
> RadioButtonList1.SelectedIndexChanged
> Dim answer As String
> answer = RadioButtonList1.SelectedValue.ToString
>
> 'Code for inserting into database...
>
> End Sub
>
>
> Tks for all the help.
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2010 codecomments.com