-1

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.

user2537735
  • 117
  • 1
  • 2
  • 11

2 Answers2

0

One way is to post the values to a controller method, save it, then render back a new view with the values.

TGH
  • 38,769
  • 12
  • 102
  • 135
  • Save part is done. After that whenever user comes to page and clicks the particular radio button, respective values should render. For this I need to create seperate view ? – user2537735 Jul 01 '13 at 04:56
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);
user2537735
  • 117
  • 1
  • 2
  • 11