私は奇妙な問題に直面しています。私はcshtmlフォームを持っています:
<label class="pre_req_questions_width">
@Html.RadioButton("radioGroup" + Model.ID, "1", (Model.ExpectedResponse == 1 ? true : false), new { id = "rbtnYes", style = "margin-top:0px; margin-right:10px;" })Yes</label>
<label class="pre_req_questions_width">
@Html.RadioButton("radioGroup" + Model.ID, "2", !(Model.ExpectedResponse == 1 ? true : false), new { id = "rbtnNo", style = "margin-top:0px;margin-right:10px;" })No</label>
フォームの送信時に、次のようなラジオ グループの値を取得しています。
int radioValue = int.Parse(fc.GetValue(controlID).AttemptedValue);
から呼び出すと正常に動作します@Html.BeginForm()
が、次のように ajax 経由でフォーム コレクションを送信しようとすると:
input = $(':input')
$.ajax({
type: "POST",
url: '@Url.Action("SavePrerequisiteQuestion", "Dashboard", new { id = @Model.ID })',
data: input,
dataType: "html",
success: function (msg) {
alert("fine");
}, error: function (req, status, error) {
// with error
alert(error);
}
});
選択/送信された値を送信するのではなく、この「1,2」のように両方の値を送信します。