Question

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.

Était-ce utile?

La solution 2

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);

Autres conseils

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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top