Questions tagged [radiobuttonfor]
68 questions
65
votes
3 answers
MVC4: Two radio buttons for a single boolean model property
I'm attempting to find the correct Razor syntax for mutually exclusive radio buttons that both reflect the value of a boolean property on my model. My model has this:
public bool IsFemale{ get; set; }
I would like to display this with two radio…

AJ.
- 16,368
- 20
- 95
- 150
44
votes
14 answers
How to Set RadioButtonFor() in ASp.net MVC 2 as Checked by default
How can i Set RadioButtonFor() as Checked By Default
<%=Html.RadioButtonFor(m => m.Gender,"Male")%>
there is way out for (Html.RadioButton) but not for (Html.RadioButtonFor)
any Ideas?

coolguy97
- 565
- 1
- 7
- 12
15
votes
2 answers
RadioButtonFor in ASP.NET MVC 2
Can someone provide a simple example of how to properly use Html.RadioButtonFor? Let's say it's a simple scenario where my model has a string property named Gender. I want to display two radio buttons: "Male" and "Female".
What is the most clean…

Larsenal
- 49,878
- 43
- 152
- 220
11
votes
2 answers
Correct Way to Code a Group of Radio Buttons using RadioButtonFor
Based on my research, the correct way to code a checkbox in MVC is as follows.
@Html.CheckBoxFor(m => m.RememberMe)
@Html.LabelFor(m => m.RememberMe)
This will render a checkbox, render a label for the checkbox, and make the label clickable, which…

Jonathan Wood
- 65,341
- 71
- 269
- 466
5
votes
1 answer
MVC5 RadioButtonFor model property not being bound properly
I'm using MVC5 with Razor views. My viewmodel has a property of type nullable enum. I made it nullable so that when the user loads the page they have to select an option and validates when they haven't selected anything.
public class…

Jen
- 1,964
- 9
- 33
- 59
5
votes
4 answers
Set @Html.RadioButtonFor as Checked by default
I am not able to set the default radio button to "Checked" !
I am using @Html.RadioButtonFor :
@Html.RadioButtonFor(m => m.UserType, "type1", new { @class="type-radio" , **@Checked="checked"** }) 1

minchiya
- 603
- 1
- 7
- 13
4
votes
3 answers
How to use jquery in MVC asp.net c#
Currently I am working on online application form using MVC asp.net .
This is my form.
What I want is that when user choose Individual radiobutton, the other radionbutton textfield should be disabled. I managed to achieved this using JSFiddle …

user3643092
- 426
- 1
- 8
- 20
4
votes
1 answer
How can I override the name attribute of a RadioButtonFor?
I'm trying to group together radiobuttons that are creating using a for loop and Razor syntax. Here is the code:
@for (var i = 0; i < Model.Sessions.Count(); i++)
{
@Html.HiddenFor(it => it.Sessions[i].Id)
…

Asgeir
- 727
- 3
- 9
- 20
4
votes
1 answer
Possible to change name of RadioButtonFor?
I am using foreach loop insoide my view to display few radiobutton rows..
sample radiobutton
Integrity
@Html.RadioButtonFor(x => x.main.ElementAt(i).nested.integrity, 1, new { id = "main_"…

RollerCosta
- 5,020
- 9
- 53
- 71
3
votes
1 answer
Radio Button doesn't reflect Model's value
I have a kendo Grid for a class, and for that class I've built an editor template to produce a radio button for one of the fields.
This radio button doesn't reflect propertie's value and is always false, although I've checked the value, by printing…

Akbari
- 2,369
- 7
- 45
- 85
3
votes
3 answers
MVC RadioButtonFor group
I have a class for a PDF
public class UIClonePDFDetail
{
public int CatalogueID { get; set; }
public List PDFToClone { get; set; }
}
The pdf class is:
public class PDF
{
public int ID{ get; set; }
…

Ketchup
- 3,071
- 4
- 20
- 23
3
votes
2 answers
How to pass IEnumerable object or data from view to controller?
I have created a strongly type view. I want to pass IEnumerable Object or data from View to Controller. Following are my Model, Controller ,view
My Model:
public class UserDetailsClass
{
public static FeedbackDatabaseDataContext context = new…

Amol
- 1,431
- 2
- 18
- 32
3
votes
1 answer
ASP.Net MVC 3 No Default Selection for RadioButon
I am developing an ASP.Net MVC 3 Web Application using Razor Views. Within the View I would like to ask the user a question which can only have a Yes/ No answer, therefore, I am planning on using two Radio Buttons.
I have a ViewModel which I pass to…

tcode
- 5,055
- 19
- 65
- 124
2
votes
2 answers
How to give names for dynamically generated radiobuttonfor
I am generating radiobuttonfor dynamically.
My code runs as,
@{int questionCount = 0;
}
@{foreach (SectionDetail sectionDetail in section.SectionDetails)
{
…
![]()
Ashiq A N
2
votes
1 answer
Razor: RadioButtonFor enum and displaying selected item in a summaryI am using RadioButtonFor to display a list of selectable items. It's part of a wizard I am using, and the last step of the wizard is a summary for the user to confirm their submission. I have everything working except for the RadioButtonFor. My…
![]()
REMESQ
|