473,624 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page Load is first then Radiobuttonlist .selecteditemCh anged, can we change this?

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 selecteditemcha nged 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.EventArg s) Handles Me.Load

If Not Page.IsPostBack Then
RadioButtonList 1.ClearSelectio n() ' I need it to be clear
each time!
leftPanel.Visib le = False
Dim users As New ArrayList
users = User_.ArrayOfUs ers
Session.Add("us ers", users)
Session.Add("i" , 0)

i = 0
details = User_.getQuesti ons(users.Item( i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
details.Clear()
'users.Clear()
Else
'RadioButtonLis t1.ClearSelecti on()
i = CType(Session(" i"), Integer)

Dim users_tmp As ArrayList
users_tmp = CType(Session(" users"), ArrayList)

If (i < users_tmp.Count - 1) Then
detailsAfterRat ing =
User_.getQuesti ons(users_tmp.I tem(i))
details = User_.getQuesti ons(users_tmp.I tem((i + 1)))

Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring

RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = Session("youRat ed")
i = (i + 1)
Session.Add("i" , i)
'details.Clear( )
'detailsAfterRa ting.Clear()
leftPanel.Visib le = True
Else
Response.Redire ct("Homepage.as px")
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 RadioButtonList 1_SelectedIndex Changed(ByVal sender
As System.Object, ByVal e As System.EventArg s) Handles
RadioButtonList 1.SelectedIndex Changed
Dim answer As String
answer = RadioButtonList 1.SelectedValue .ToString

'Code for inserting into database...

End Sub
Tks for all the help.

Mar 29 '07 #1
2 4004
move your page load code to prerender

-- bruce (sqlwork.com)

ri************* ******@googlema il.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 selecteditemcha nged 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.EventArg s) Handles Me.Load

If Not Page.IsPostBack Then
RadioButtonList 1.ClearSelectio n() ' I need it to be clear
each time!
leftPanel.Visib le = False
Dim users As New ArrayList
users = User_.ArrayOfUs ers
Session.Add("us ers", users)
Session.Add("i" , 0)

i = 0
details = User_.getQuesti ons(users.Item( i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
details.Clear()
'users.Clear()
Else
'RadioButtonLis t1.ClearSelecti on()
i = CType(Session(" i"), Integer)

Dim users_tmp As ArrayList
users_tmp = CType(Session(" users"), ArrayList)

If (i < users_tmp.Count - 1) Then
detailsAfterRat ing =
User_.getQuesti ons(users_tmp.I tem(i))
details = User_.getQuesti ons(users_tmp.I tem((i + 1)))

Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring

RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = Session("youRat ed")
i = (i + 1)
Session.Add("i" , i)
'details.Clear( )
'detailsAfterRa ting.Clear()
leftPanel.Visib le = True
Else
Response.Redire ct("Homepage.as px")
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 RadioButtonList 1_SelectedIndex Changed(ByVal sender
As System.Object, ByVal e As System.EventArg s) Handles
RadioButtonList 1.SelectedIndex Changed
Dim answer As String
answer = RadioButtonList 1.SelectedValue .ToString

'Code for inserting into database...

End Sub
Tks for all the help.
Mar 29 '07 #2
On Mar 29, 11:24 pm, ricardo.sobral. san...@googlema il.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 selecteditemcha nged 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.EventArg s) Handles Me.Load

If Not Page.IsPostBack Then
RadioButtonList 1.ClearSelectio n() ' I need it to be clear
each time!
leftPanel.Visib le = False
Dim users As New ArrayList
users = User_.ArrayOfUs ers
Session.Add("us ers", users)
Session.Add("i" , 0)

i = 0
details = User_.getQuesti ons(users.Item( i))
Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring
details.Clear()
'users.Clear()
Else
'RadioButtonLis t1.ClearSelecti on()
i = CType(Session(" i"), Integer)

Dim users_tmp As ArrayList
users_tmp = CType(Session(" users"), ArrayList)

If (i < users_tmp.Count - 1) Then
detailsAfterRat ing =
User_.getQuesti ons(users_tmp.I tem(i))
details = User_.getQuesti ons(users_tmp.I tem((i + 1)))

Image.ImageUrl = details(1).ToSt ring
lblLastChecked. Text = details(3).ToSt ring

RatedImage.Imag eUrl = detailsAfterRat ing(2).ToString
lblRating.Text = detailsAfterRat ing(5).ToString
lblPastRate.Tex t = Session("youRat ed")
i = (i + 1)
Session.Add("i" , i)
'details.Clear( )
'detailsAfterRa ting.Clear()
leftPanel.Visib le = True
Else
Response.Redire ct("Homepage.as px")
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 RadioButtonList 1_SelectedIndex Changed(ByVal sender
As System.Object, ByVal e As System.EventArg s) Handles
RadioButtonList 1.SelectedIndex Changed
Dim answer As String
answer = RadioButtonList 1.SelectedValue .ToString

'Code for inserting into database...

End Sub

Tks for all the help.
Simply redesign it a little bit, as per

Sub Page_Load(...)

If Not Page.IsPostBack Then
LoadNewQuestion ()
End If

End Sub

Sub RadioButtonList 1_SelectedIndex Changed
'Code for inserting into database...
......
LoadNewQuestion ()
End Sub

Sub LoadNewQuestion ()
RadioButtonList 1.ClearSelectio n()
' Loading new question
.......
End Sub
Mar 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
5658
by: KathyB | last post by:
Hi, On Page Load (if not postback), the user selects a choice from dropdownlist1. On SelectedItemChanged for dropdownlist1, dropdownlist2 is populated and the user selects an item. I cannot find a combination where I can RETAIN both values during postback...if I put if not posback on the change event of
3
8990
by: William LaMartin | last post by:
If I create a RadioButtonList with, say, two items, then after the page loads and I select one of the items and then click on a button whose click event contains some code to display the RadioButtonlList's selected value, there is nothing. On a postback, with the dynamically created button list visible on the page and the first item selected, if I try some code like "If Me.RadioButtonList1.Items(0).Selected = True Then.......", then I...
0
1552
by: Niks | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary in the bulleted list on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One for Submit, Reset and Exit. If submit is pressed page should be validated and submit (insert into
3
2597
by: Arun K | last post by:
Hi, I am creating a simple .aspx page to add some fields with validation. I have used different .NET validations like REquiredFieldValidator, RegularExpressionValidator and showed the summary in the bulleted list on top. I have 3 text boxes, and two RadioButtonList. and 3 buttons. One for Submit, Reset and Exit. If submit is pressed page should be validated and submit (insert into
0
1237
by: Goober at christianDOTnet | last post by:
I'm wanting to fix the following on a web page without really re-inventing anything. What I have is a vb web page with a radiobuttonlist where I can pick Current or History year. Underneath that is a listbox that has a set of reports in it, some for current year, some for history year. If Current year is chosen, 6 reports (depending on user access level) are listed, on the History one, 2 are listed (also depending on user access...
1
2088
by: jmgro | last post by:
I have spent way too much time trying to solve the following problem: I have a datalist with a timer in the footer template. It works wonderfully except when the user pages back, then forward, and the counter is reset. I saw in one of Kevin Spencer's comments not to put the timer in javascript on the load function, but I have to get the script to run before the page is rendered, otherwise my timer is not displayed. I have a flag "Hidden...
4
4877
by: chaz | last post by:
here is the html : <br> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="<%=LABEL_WIDTH%>" class="formtext"><%= HTEXT("Connection type:")%></td> <td class="formtext"> <input type="radio" class="inputRadio" id="dbStatus" name="dbStatus" value="1" onclick="changeDbStatus(1)" <%if dbStatus=1 then%checked
9
3181
by: Gummy | last post by:
Hello, I created a user control that has a ListBox and a RadioButtonList (and other stuff). The idea is that I put the user control on the ASPX page multiple times and each user control will load with different data (locations, departments, etc.).
0
1274
by: Jeffrey Walton | last post by:
Hi All, Sorry about this beginner question (I'm coming up from Visual C++ or Down from VB)... Also, pickings are slim for this topic on MSDN . does not really apply, but it was a keyword hit ("SelectedItemChanged"). Does any one know how to receive this notification? I'm not receiving it. What I done so far: Hightlight the TreeView in Design Mode, and then switching to Properties->Events: SelectedItemChanged is not an available...
0
8234
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8620
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1784
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.