I need to pass Views names to PartialViewResult
from Jquery, single Controller & single PartialViewResult
method to use entire application,
working controller code:-
public PartialViewResult addNew(string MenuId)
{
return PartialView(@"~/Views/Test/Add.cshtml");
}
html jquery method:-
$('#btn_add').click(function (e) {
window.location.href = '@Url.Action("addNew", "Home")?MenuId=' + 1;
});
this code working fine but why should we add-code the views name in controller rather pass views name from jquery method, it will be very easy to maintain and very easy method for code
Expected output: controller code:-
public PartialViewResult addNew(string MenuId, string ViewNames)
{
return PartialView("@~/"+ ViewNames);
//return PartialView(@"~/Views/Test/Add.cshtml");
}
Expected output: html jquery method:-
$('#btn_add').click(function (e) {
window.location.href = '@Url.Action("addNew", "Home")?MenuId=' + 1 + '&viewname=' + 'Views/Test/Add.cshtml';
});
above code showing An error occurred while processing your request. can anybody share your ideas?..
I need to pass views name from jquery method with single PartialViewResult method in MVC Controller