Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submitting forms with radio buttons without a Submit button 1

Status
Not open for further replies.

StevenB

IS-IT--Management
Sep 25, 2000
247
US
Hi folks,

Well, judicious use of Google failed to turn up an answer to this, and you guys are always fast to reply, so here goes again.

My little ASP.NET application involves a simple (well, for you) voting engine. My page displays a suggestion pulled at random from my database, along with a set of radio buttons with numbers. Users will vote on each suggestion by clicking on the radio buttons. My radio buttons look like this:

Code:
            <asp:RadioButtonList ID="VoteList" runat="server" RepeatDirection="Horizontal" AutoPostBack="True" BackColor="#E0E0E0" BorderColor="#404040" BorderStyle="Solid" BorderWidth="2px">
                <asp:ListItem Value="1">1</asp:ListItem>
                <asp:ListItem Value="2">2</asp:ListItem>
                <asp:ListItem Value="3">3</asp:ListItem>
                <asp:ListItem Value="4">4</asp:ListItem>
                <asp:ListItem Value="5">5</asp:ListItem>
                <asp:ListItem Value="6">6</asp:ListItem>
                <asp:ListItem Value="7">7</asp:ListItem>
                <asp:ListItem Value="8">8</asp:ListItem>
                <asp:ListItem Value="9">9</asp:ListItem>
                <asp:ListItem Value="10">10</asp:ListItem>
            </asp:RadioButtonList>

I want this form to work so that as soon as a user clicks on a radio button, their vote is immediately submitted. (One-click voting, instead of selecting a button and then clicking on Submit.) As soon as the vote is recorded, the page will be refreshed with a new suggestion displayed.

Pretty much like this site:
I haven't been able to figure out how to make this happen without requiring the user to select a radio button and then click on a Submit button of some kind. I suspect this somehow will involve the whole "AutoPostBack="True"" concept? I also know that Buttons have an OnClick event, but haven't been able to figure out how to call the code that would submit the vote to the database.

Thoughts? Feedback always appreciated.

Steve
 
The AutoPostBack method will write the necessary javascript to post the form back when the user makes a selection. You just have to create a SelectedIndexChanged event to handle the selection that the user made.


____________________________________________________________
Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]

Need help finding an answer? Try the Search Facility or read FAQ222-2244.
 
Use the SelectedIndexChanged event of the radiobuttonlist to call your db code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top