Click here to Skip to main content
13,138,372 members (49,788 online)
Rate this:
Please Sign up or sign in to vote.
<input type="radio" name="GenderSelect" value=1 />Male<br/>
<input type="radio" name="GenderSelect" value=0 />Female

I have got a var called Gender. I wana check one of these 2 buttons based on Gender's value. if(gender==1) male is checked otherwise female. I need server-side ( code snippet not js.
Posted 14-Dec-12 21:11pm
Updated 14-Dec-12 21:33pm
Krunal Rohit 15-Dec-12 3:15am
Your question is uncertain, Place your JS/C# code here..
Tadit Dash 15-Dec-12 3:22am
Do you want to do it in JavaScript or Server Side?
cs101000 15-Dec-12 3:29am
Server Side
rahkan 15-Dec-12 9:05am
Where's your server-side code that you're using?
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Use <asp:RadioButton ID="RadioButton1" runat="server"/> tag instead of input type. You can easily check that which value got selected.
cs101000 21-Dec-12 4:08am
You mean like this:

<asp:radiobutton xmlns:asp="#unknown" name="GenderSelect" value="1" style="padding: 0px">male

<asp:radiobutton xmlns:asp="#unknown" name="GenderSelect" value="0" style="padding: 0px">female

When I use this the texts 'male' and 'female' are displayed but the buttons are not displayed at all.
VishwaKL 21-Dec-12 4:25am
drag and drop radio button from the tool box, no need to write it down buddy,
cs101000 21-Dec-12 8:29am
Im afraid webmatrix doesnt have a toolbox!
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

<input type="radio" name="GenderSelect" value=1 runat="server"/>Male<br/>
<input type="radio" name="GenderSelect" value=0 runat="server"/>Female
cs101000 21-Dec-12 8:32am
What does that 'runat' attribute do? And how can I specify my condition then?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170915.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100