This got solved. We can use JQuery to achive tgis
View
--------
var url = '@Url.Action("YourActionName", "YourControllerName")';
$.post(url, 'ID=' + radio button Id , function (data) {
$('#txtBox1').val(data.Key1);
$('#txtBox2').val(data.Key2);
$('#txtBox3').val(data.Key3);
}
Controller
----------
Inside your action method , construct a JSON string as showed below and send back to JQuery Function.
var dataTest = new { "Key1"= "value1","Key2"= "value2", "Key3"= "value3" };
return Json(dataTest, JsonRequestBehavior.AllowGet);
call action methods in @Html.RadioButtonFor in MVC3
-
02-06-2022 - |
Вопрос
I have 3 radio buttons and 2 text boxes in a view. Initially I need to save the values in DB through the view and once its saved I need to display the saved values in the particular view according to which radio button I clicked.
Решение 2
Другие советы
One way is to post the values to a controller method, save it, then render back a new view with the values.
Не связан с StackOverflow