MVC 4 Radio Button List
-
Hi, I want to develop a Survey module using MVC4, for that i have a set of questions for each questions i have 4 options & these options should be radio button in the application and all questions will be having same options EX, Agree,Disagree, Strongly agree,Strongly Disagree. How can i achieve this using MVC4. I tried several links but no link is helping out EX: Tried This[^] NOTE: I am a beginner in MVC
-
Hi, I want to develop a Survey module using MVC4, for that i have a set of questions for each questions i have 4 options & these options should be radio button in the application and all questions will be having same options EX, Agree,Disagree, Strongly agree,Strongly Disagree. How can i achieve this using MVC4. I tried several links but no link is helping out EX: Tried This[^] NOTE: I am a beginner in MVC
Hi Vishal, So you mean that, let say Quetion1, Question2, Question3,... and for each question you will have Option1, Option2, Option3, Option4 and for each question you will have - Agree,Disagree, Strongly agree, Strongly Disagree, Like Question1 Option1, Option2, Option3, Option4 Disagree, Agree, Strongly Agree, Strongly Disagree Question2
Option1, Option2, Option3, Option4
Disagree, Agree, Strongly Agree, Strongly Disagree..................... Right? Thanks Raviranjan
-
Hi Vishal, So you mean that, let say Quetion1, Question2, Question3,... and for each question you will have Option1, Option2, Option3, Option4 and for each question you will have - Agree,Disagree, Strongly agree, Strongly Disagree, Like Question1 Option1, Option2, Option3, Option4 Disagree, Agree, Strongly Agree, Strongly Disagree Question2
Option1, Option2, Option3, Option4
Disagree, Agree, Strongly Agree, Strongly Disagree..................... Right? Thanks Raviranjan
-
Hi Vishwa, Below i am giving idea how you can do it. In View on top @model IEnumerable--> This is basically the list of Question that you have to return from controller method Then HTML Code for Displaying the Question and their option @foreach (Question question in Model) { @Html.DisplayFor(modelItem => question.QuestionText) foreach (Option option in question.Options) { option.OptionText : @Html.RadioButtonFor(opt=>option.OptionID,option.OptionValue) } <HTML for like> Agree, DisAgree,... } The Class of Question and Option will be like below public class Option{ public int OptionID{get;set;} public string OptionText{get;set;} public string OptionValue{get;set;} } public class Question{ public string QuestionText{get;set;} public List Options{get;set;}//This will contain all 4 option } Class name and properties you can put whatever you want, i have just wrote sample. Let me know if you have any doubt. Thanks Raviranjan
-
Hi Vishwa, Below i am giving idea how you can do it. In View on top @model IEnumerable--> This is basically the list of Question that you have to return from controller method Then HTML Code for Displaying the Question and their option @foreach (Question question in Model) { @Html.DisplayFor(modelItem => question.QuestionText) foreach (Option option in question.Options) { option.OptionText : @Html.RadioButtonFor(opt=>option.OptionID,option.OptionValue) } <HTML for like> Agree, DisAgree,... } The Class of Question and Option will be like below public class Option{ public int OptionID{get;set;} public string OptionText{get;set;} public string OptionValue{get;set;} } public class Question{ public string QuestionText{get;set;} public List Options{get;set;}//This will contain all 4 option } Class name and properties you can put whatever you want, i have just wrote sample. Let me know if you have any doubt. Thanks Raviranjan