Hi,
I have a fairly larger form which has multiple fields, I need to pass the values of those fields to an action method, assigns some values to another view and opens it. I have been trying to post those values using ajax post the action method is getting executed but the View stays the same.
I have not used any model binding for the first view from where I am posting the values into an action method, hence I tried to use the ajax call, is there any way I can post the values to action method and transfer to new view that I wanted after action method execution by using ajax call.
I know I can achieve it by using Model binding and submit but I don't have model for the View so can I do it by using ajax call itself.
My ajax call and action methods are as below:
$("#btnChangeReport").click(function ()
{
debugger;
var res;
var token = $('[name=__RequestVerificationToken]').val();
$.ajax({
type: "POST",
url: '@Url.Action("ShowLegalEntityReport", "Report")',
contentType: "application/json;charset=utf-8",
dataType: 'json',
async: false,
headers: { '__RequestVerificationToken': token },
data: JSON.stringify({
'legalEntityNumber': txtLegalEntityNumber.value, 'lENumOperator': "", 'legalEntityName': txtLegalEntityName.value, 'lENameOperator': ""
, 'taxId': txtTaxId.value, 'taxIdOperator': "", 'submittingCounty': $('#idDDLForCounty').val(), 'submCountyOperator': "", 'legalEntityCity': txtLegalEntityCity.value, 'lECityOperator': ""
}),
success: function (result)
{
}
});
});
Action method is as below:
public ActionResult ShowLegalEntityReport(string legalEntityNumber, string lENumOperator, string legalEntityName, string lENameOperator
, string taxId, string taxIdOperator, string submittingCounty, string submCountyOperator, string legalEntityCity, string lECityOperator)
{
ReportViewer reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.SizeToReportContent = true;
reportViewer.Width = Unit.Percentage(900);
reportViewer.Height = Unit.Percentage(700);
DataRetrieveServiceClient drsc = new DataRetrieveServiceClient();
DataTable dt = CommonFunctions.ToDataTable(drsc.GetLegalEntityReport(legalEntityNumber, lENumOperator, legalEntityName, lENameOperator, taxId, taxIdOperator
, submittingCounty, submCountyOperator, legalEntityCity, lECityOperator));
reportViewer.LocalReport.ReportPath = Request.MapPath(Request.ApplicationPath) + @"\Reports\LegalEntityReport.rdlc";
reportViewer.LocalReport.DataSources.Add(new ReportDataSource("LegalEntityDataSet", dt));
ViewBag.ReportViewer = reportViewer;
return View();
}
Please help me in this regards any help is appreciated - thanks in advance
What I have tried:
googling searching asking colleagues any help that's possible