Wrox Programmer Forums
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2010, 04:00 AM
Registered User
 
Join Date: Aug 2010
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Radiobutton returns

Any way to change RadioButton returns from "True" / "False" to anything else, like, "Yes"/"No" or "male" / "female"
Thanks.
Oguchi
 
Old August 12th, 2010, 12:51 AM
Authorized User
 
Join Date: Aug 2010
Posts: 10
Thanks: 0
Thanked 1 Time in 1 Post
Default

I'm not exactly an expert on coding, and I'm not sure I understand what you are asking.

If you have two radio buttons, that allow them to select either male or female.

And they select male.

Then there should be an IF statement there to determine which one they selected and at that point you could use a variable to store that information in, right?

I'm just learning all of this, I think I could put some VB code togethor for an example if you wanted me to. But, I'm just responding to help teach myself for the most part. :)
 
Old August 18th, 2010, 12:15 AM
Friend of Wrox
 
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

I believe what you want is the value attribute of the radio buttons. Something like this.

Code:
<ul>
   <li>
      <input type="radio" name="SelectPages" id="SelectPagesPageA" value="PageA" />
        <label for="SelectPagesPageA">Page A</label>
    </li>
    <li>
      <input type="radio" name="SelectPages" id="SelectPagesPageB" value="PageB" />
      <label for="SelectPagesPageB">Page B</label>
   </li>
</ul>
The label tag uses the for attribute to tie the descriptive text "Page A" to the correct form control. The name attribute of the radio button is the text you look for in the request object on the server side to determine what the user selected. In order to get the classic radio button behavior (where users can only select one button), you must apply the same name to each radio button in the set. If you give a different name to a radio button, it will be in a different set. When you ask the Request object for the name, it will return the value to you (in this case "PageA" or "PageB". Based on that value you can write whatever code you need to cover each case.

You'll note that I like to combine the name and value together to create a quick and easy id. Usually I like the name and id to be the same in form elements but for radio buttons that's just not possible; the name values must be identical where ids are always unique. This is just one of the annoying inconsistencies of form elements. So I stay as close as I can by using the name in my ids, but adding the radio value as well to ensure that the id is unique. You can also see that as closely as possible, my values are identical to the descriptive text. My feeling is, if it's a good way to describe it to your users, it's a good way to identify it to yourself in code (and vice versa).
__________________
-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.





Similar Threads
Thread Thread Starter Forum Replies Last Post
RadioButton with GridView Manoj Bisht ASP.NET 3.5 Professionals 1 March 18th, 2009 12:13 PM
Hiding Radiobutton and IE6 elwappo CSS Cascading Style Sheets 7 February 25th, 2009 08:46 AM
select either textarea or radiobutton pavani ASP.NET 2.0 Basics 1 March 21st, 2008 04:35 AM
RadioButton in Datagrid FLEX abhishekchess1 ASP.NET 1.0 and 1.1 Professional 3 September 28th, 2007 01:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.