Solved

Radio button rating system

Posted on 2004-08-06
6
663 Views
Last Modified: 2008-03-06
Hello all!

I am newly getting into creating ASP pages.  I need to create a very simple data entry form so that the user can rate several items.  What I want to have is the item in question on the left hand side, and then on the right hand side a control that has 1-10 layed out like this.

Item 1 -           1 2 3 4 5 6 7 8 9 10

With a radio button above each number.  Only one of the buttons can be checked at a time.

Is there any easy way to go about doing this?  Ive tried in Web Matrix but I can't seem to create a radio button with the button on top and the text on the bottom.

Any help is appreciated.

Chris
0
Comment
Question by:Krys_Wilson
6 Comments
 
LVL 33

Expert Comment

by:raterus
ID: 11739160
I'd make a UserControl that would do this if I were you.  I'm imagining that you are going to reuse this...
0
 
LVL 3

Expert Comment

by:GrumbleBot
ID: 11739476
I would probably suggest what raterus said too.

But if you are not sure on how to do that you can do it very simply by adding a radiobutonlist and adding ten items giving each one a value 0-9 and text being a space. Then create 10 labels and number them 0-9 and position them directly above the radio buttons. You can then add an event for SelectedIndexChanged.

Hope this helps.
0
 
LVL 33

Expert Comment

by:raterus
ID: 11739540
The only problem I see with that solution is that the radiobuttonlist is going to render in it's own table, so even if you created some labels below it, there is no html guarantee that they will line up correctly.  Another possibility which would work great if you could figure out how is to just use the radiobuttonlist, but override the render event and separate the text from the button like you want it.  Not easy though..
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 8

Accepted Solution

by:
boulder_bum earned 125 total points
ID: 11739796
"Is there any easy way to go about doing this?"

Very much yes, with the RadioButtonList mentioned above.

Example:

http://it.maconstate.edu/tutorials/ASPNET/ASPNET06/aspnet06-01.aspx

<SCRIPT runat="server">

Sub Page_Load

  If Not Page.IsPostBack Then

    MyList.Items.Add(New ListItem("Red","R"))
    MyList.Items.Add(New ListItem("Green","G"))
    MyList.Items.Add(New ListItem("Blue","B"))

    MyList.Items(0).Selected = True

  End If

End Sub

Sub GetSelectedButton (Src As Object, Args As EventArgs)

  Dim Item As ListItem
  For Each Item in MyList.Items
    If Item.Selected = True Then
      TextProperty.Text = Item.Text
      ValueProperty.Text = Item.Value
    End If
  Next

End Sub

</SCRIPT>

<asp:RadioButtonList id="MyList" runat="server"/>

<asp:Button Text="Get Button" OnClick="GetSelectedButton" runat="server"/>
<b>Item.Text: </b><asp:TextBox id="TextProperty" Size="1" runat="server"/>
<b>Item.Value: </b><asp:TextBox id="ValueProperty" Size="1" runat="server"/>





For aligning text ON TOP of the radio button list, you can make a table with 2 rows, one for each rating/radio button pair (rating on top row, radio button on second). You'd then assign each RadioButton's GroupName property to be identical.

This doc describes processing:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskrespondingtouserselectioninradiobuttongroup.asp


0
 
LVL 5

Author Comment

by:Krys_Wilson
ID: 11740042
Ive got to leave work early, I will defiantely check over these solutions and let you guys know.

Thanks for the help!

Chris
0
 
LVL 5

Author Comment

by:Krys_Wilson
ID: 11755528
Thanks everyone for responding and for waiting over the weekend!  I appreciate all the posts and I went with Boulder Bum's solution.

Thanks again!

Chris
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now