Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have 2 radiobutton but if select any button it alwaz shows false
i.e
HTML
<div class="radio">
													<label>
														<input name="cycle" type="radio" class="ace" id="Cprocess" value="True" />
														<span class="lbl"> Cycle In Process</span>
													</label>
												</div>

<div class="radio">
													<label>
														<input name="cycle" type="radio" class="ace" value="True" id="CstartEnd"/>
														<span class="lbl">Cycle Start And End</span>
													</label>
												</div>

but in controller it alwaz shows false
i.e
C#
public ActionResult Add(Models.Machine _machine)
{
    //some code
}
Posted
v3
Comments
Bh@gyesh 3-Jun-14 4:52am    
It means you are checking CStartEnd.Checked and it shows false instead of true, isn't it?
Member 9027346 3-Jun-14 5:02am    
yes
Bh@gyesh 3-Jun-14 5:41am    
in which event you access this? can you share me your code?
Member 9027346 3-Jun-14 6:18am    
public ActionResult Add(Models.Machine _machine)
{
//some code
}

1 solution

This is because you are using same 'name' attribute which means that u can select any one value but in the above code you have given value as true for both the radio button so make any of the radio button value as false as per your requiremnt.

XML
<div class="radio">
 <label>
 <input name="cycle" type="radio" class="ace" id="Cprocess" value="True" />
<span class="lbl"> Cycle In Process</span>
 </label>
 </div>

<div class="radio">
<label>
 <input name="cycle" type="radio" class="ace" value="False" id="CstartEnd"/>
 <span class="lbl">Cycle Start And End</span>
  </label>
 </div>
 
Share this answer
 
v2

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900