Click here to Skip to main content
11,411,494 members (62,822 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET HTML Webmatrix
<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 22:11pm
Edited 14-Dec-12 22:33pm
Krunal Rohit at 15-Dec-12 3:15am
Your question is uncertain, Place your JS/C# code here..
Tadit Dash at 15-Dec-12 3:22am
Do you want to do it in JavaScript or Server Side?
cs101000 at 15-Dec-12 3:29am
Server Side
rahkan at 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 at 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 at 21-Dec-12 4:25am
drag and drop radio button from the tool box, no need to write it down buddy,
cs101000 at 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 at 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
0 OriginalGriff 213
1 Sergey Alexandrovich Kryukov 149
2 Sascha Lefévre 110
3 Dave Kreskowiak 90
4 RyanDev 75
0 Sergey Alexandrovich Kryukov 8,920
1 OriginalGriff 6,983
2 Maciej Los 3,430
3 Abhinav S 3,248
4 Peter Leow 3,059

Advertise | Privacy | Mobile
Web03 | 2.8.150414.5 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2015
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