Click here to Skip to main content
16,017,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
[HttpPost]
public JsonResult Ajax(string AJAXParameter1)
{     
    List<string> data = new List<string>();
    data.Add("AJAXParameter1=" + AJAXParameter1);
    return Json(new { data, result = "OK" });
}


C#
If parameter AJAXParameter1 recieves value as passport i want to display view that contains fileds related to passport. If it recieves value as pan i want to render some different view that allow us to add pan card related details. For pan and passport i have models. Based on Id i want to generate view.
Posted

1 solution

C#
[HttpPost]
public ActionResult Ajax(string AJAXParameter1)
{     
    if (AJAXParameter1 == "passport")
    {
        // if you want to return a model too then add it as a second parameter
        return View("~/Views/MyController/Password.cshtml");
    }
    else
    {
        return View("~/Views/MyController/SomeOtherView.cshtml");
    }
}
 
Share this answer
 
Comments
Member 10624821 8-Jan-16 6:36am    
but this is my Json method. public JsonResult Ajax(string AJAXParameter1).
F-ES Sitecore 8-Jan-16 7:20am    
A view is html, JSON is...well, JSON :) Either the calling code expects json that it will process, or html that it will show. You might need to explain what you're doing a bit better as it isn't clear.
Member 10624821 8-Jan-16 6:37am    
Or how can i use that Ajaxparameter1 variable in other action methods. So that method will work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900