Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Radio button rating system

Posted on 2004-08-06
6
666 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASCX file or a newer alternative? 1 40
encoding an href string 2 24
LINQ Select all records by MAX data syntax help 1 17
Need syntax help building hyperlink 2 20
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…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

790 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