I want to do something like this; - I'll send a Post request to an action(partial view or something else, i don't know) method with javascript. - Before this action will show me a partial view. - Partial View will also have a form and the user will enter data. - Finally, I will send this data back as the JSON data of my javascript post request.
[HttpPost]
public ActionResult GetInformation()
{
// The ShowForm method returns Partial View, I know.
// But how do I get and return the data entered in PartialView?
var data = ShowForm();
return Json(data);
}
public PartialViewResult ShowForm()
{
.....
return new PartialViewResult();
}
As above I want a method of returning JSON data. However, I need to add the PartialView image to the Html page with C #. Then I have to take the data from the form and return it as json.
Can something like this be done? I know my samples can be ridiculous. Because I had no idea.
bodysection(where it will only be used as a structure) of the modal and validate it on the button click of the modal. By this approach, your data will still be in a single controller's context and you don't need to call the partial view fromserver-side(controller side).