我在视图中有3个单选按钮和2个文本框。最初我需要通过视图保存DB中的值,一旦保存,我需要根据我点击的单选按钮在特定视图中显示保存的值。
答案 0 :(得分:0)
一种方法是将值发布到控制器方法,保存,然后使用值渲染回新视图。
答案 1 :(得分:0)
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);