Click here to Skip to main content
12,503,591 members (51,417 online)
Rate this:
 
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 (asp.net) code snippet not js.
Posted 14-Dec-12 21:11pm
Updated 14-Dec-12 21:33pm
v3
Comments
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
 
good
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.
  Permalink  
v2
Comments
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
 
good
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
  Permalink  
Comments
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 | Mobile
Web01 | 2.8.160919.1 | Last Updated 21 Dec 2012
Copyright © CodeProject, 1999-2016
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