Click here to Skip to main content
15,918,624 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
//Getting gateway name from database
HTML
<div>
 <label class="for">;
    Payment method:
   </label>;
       @foreach (var pgName in Model.lstInfo)
           {
              <span class="formfield jqtransform">
              @Html.RadioButton("PGName", pgName.ID, pgName.PGName)
              </span>
              <label class="for" for="PGName">@pgName.PGName
           }
 </div>
Posted
Updated 26-Oct-15 1:24am
v3
Comments
Krunal Rohit 26-Oct-15 3:40am    
And the issue is ?

-KR
MayankSemwal 26-Oct-15 3:46am    
no issue, I don't know how to to it. Can you tell how can i achieve that
Krunal Rohit 26-Oct-15 3:58am    
You want to validate the radio buttons after the form submission or at the time of submission ?

-KR
MayankSemwal 26-Oct-15 4:01am    
Yes.
MayankSemwal 26-Oct-15 6:12am    
Can you help or not.?

1 solution

Assuming you are asking that, how to check whether particular radio button is checked or not, here is solution to check in jQuery-

JavaScript
var isThisChecked = $('#YourId').is(':checked');


You can put in post method.
 
Share this answer
 
Comments
MayankSemwal 28-Oct-15 1:53am    
Umarfarukh7@ I am doing the same, but the problem is how can i include ID in @Html.RadioButton(), it doesn't accept ID as fourth field.
Umarfarukh7 28-Oct-15 2:01am    
@Mayank
Something like this -
@Html.RadioButtonFor(m => m.ID, pgName.PGName, new { @Id = "rdoPGName" })

Also, try to look at the ViewSource, it will help you out with the final html code generated.
MayankSemwal 28-Oct-15 2:06am    
this is I am able to do, but as you can see i have 3 fields already and i am not able to add @new{} as a fourth field. Is there anyway i can do that
Umarfarukh7 28-Oct-15 2:13am    
Instead @Html.RadioButton, use @Html.RadioButtonFor(), there you don't need 4th parameter
MayankSemwal 28-Oct-15 2:27am    
Can you tell me how I achieve this using the above 4 parameters i am using

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