radiobuttonfor

MVC3 @Html.RadioButtonfor Pass data from view to controller

无人久伴 提交于 2019-12-02 01:42:36
Basically what I am trying is to create a feedback form with a question which has four answers (Radio Button) using MVC. In View : I am able to get questions and answers in view with radiobutton to each answer. In Controller : I am confused here. I would like to send selected question & there answers from View to controller. My view : @model IEnumerable SQLOperation.Models.QuestionClass.Tabelfields @{int i = 0;} @foreach (var item in Model) { using (Html.BeginForm("Question", "home", new {email=item.Email})) { @Html.DisplayFor(modelItem => item.QuestionName,item) <br /><br /> if (item.Option1

MVC3 @html.radiobuttonfor

久未见 提交于 2019-12-02 00:59:23
Here is my class : public class QuestionClass { public static FeedbackDatabaseDataContext context = new FeedbackDatabaseDataContext(); public class Tabelfields : Question { //public int QuestionID { get; set; } //public string Email { get; set; } //public string QuestionName { get; set; } //public string Option1 { get; set; } //public string Option2 { get; set; } //public string Option3 { get; set; } //public string Option4 { get; set; } public string SelectedOption { get; set; } } public static List<Question> getallQuestion(string email) { var list = (from q in context.Questions where q.Email

Radio Button doesn't reflect Model's value

耗尽温柔 提交于 2019-12-01 22:16:59
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 it on the form, and I'm sure it's true . If I set a default value for that field, the radio button will reflect that value, regardless of the real value of the field. I should note that I'm using a client template to display a text for that field, and it works fine. This is the Grid: @(Html.Kendo().Grid<Class>() .Name("Grid") .Columns(columns => {

RadioButtonFor in ASP.NET MVC 2

拈花ヽ惹草 提交于 2019-11-30 17:58:27
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 way to implement this while retaining the selected value in an Edit view? Mac This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too (@Larsenal it also includes labels with the "for" attribute) Male: <%= Html.RadioButtonFor(x => x.Gender, "Male") %> Female: <%= Html.RadioButtonFor(x => x.Gender, "Female"

RadioButtonFor in ASP.NET MVC 2

拜拜、爱过 提交于 2019-11-30 01:12:08
问题 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 way to implement this while retaining the selected value in an Edit view? 回答1: This question on StackOverflow deals with RadioButtonListFor and the answer addresses your question too (@Larsenal it also includes labels with the "for" attribute) 回答2:

MVC4: Two radio buttons for a single boolean model property

风流意气都作罢 提交于 2019-11-28 17:24:28
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 buttons, one "Male" and the other "Female," but everything I've tried so far has not reflected the actual value of the IsFemale property on the model. Currently, I have this: @Html.RadioButtonFor(model => model.IsFemale, !Model.IsFemale) Male @Html.RadioButtonFor(model => model.IsFemale, Model.IsFemale) Female This seems to persist the value correctly

MVC4: Two radio buttons for a single boolean model property

霸气de小男生 提交于 2019-11-27 10:25:55
问题 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 buttons, one "Male" and the other "Female," but everything I've tried so far has not reflected the actual value of the IsFemale property on the model. Currently, I have this: @Html.RadioButtonFor(model => model.IsFemale, !Model.IsFemale) Male @Html