ASP 101 - Active Server Pages 101 - Web01
The Place ASP Developers Go!



Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates
ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





FAQ for the Radio Button sample:


How do I write the code to get a group of radio buttons with the same name to maintain their state?

Good question. It's really no more difficult then getting a single radio button to maintain its state, it just takes more code. Take a look at the following block of code.

  Multiple Radio Buttons With The Same Name That Maintain Their State:
  <input type="radio" name="multiple_state" value="1"
    <% If Request.QueryString("multiple_state") = "1" Then Response.Write "checked=""checked""" %>
  />
  <input type="radio" name="multiple_state" value="2"
    <% If Request.QueryString("multiple_state") = "2" Then Response.Write "checked=""checked""" %>
  />
  <input type="radio" name="multiple_state" value="3"
    <% If Request.QueryString("multiple_state") = "3" Then Response.Write "checked=""checked""" %>
  />

The code above checks the value of the radio button parameter that was passed to the page once for each radio button in the group. When the value of the parameter matches the value of the radio button that we're currently checking for, it sets the "checked" parameter of that radio button so that button is the one selected when the page is rendered. It's really quite simple, but it's a shame it's such a tedious task. Not having to manage state in this manner is one of the great benefits of moving to ASP.NET web controls since they handle all the state managment for you.

Was your question not answered above?

Ask a new question

Please note: This form is only for submitting questions about the sample for us to consider including in the FAQ. If we feel the question merits inclusion, we will include it along with a reply. We will not respond to your email individually.


Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers