Reputation: 374
I need to pass some HTML markup to the controller (please see my detalle variable), using jquery, in the action is that I have the problem when I try to send the detalle, it said that is not found, somebody can help me?
$('#BtnPrint').click(function() {
var detalle = "<br><br>";
detalle += " Yo: <b>" + '@Model.DoctorText' + "</b>";
if ('@Model.Exequartur' != "") {
detalle += ", exequatur: <b>" + '@Model.Exequartur' + "</b> <br>";
}
detalle += " certifico haber examinado a: <b>" + '@Model.PatientName' + "</b> <br>";
@*if (@Model.ide != "")
{
detalle += " cedula: <b>" + txtcedula.Text + "</b> <br>";
}*@
detalle += " quien presenta: <b>" + '@Model.Affections' + "</b> <br>";
detalle += " por lo que recomiendo: <b>" + '@Model.Recomendations' + "</b> <br>";
detalle += "<br> dado en: <b>" + ' @Model.Place' + "</b>, " + '@Model.MedicalCertificateDate' +
" <br>";
detalle += "<br><br><br><br> ";
$('#myVar').val(detalle);
var win = window.open(
"@Url.Action("DetailsPrint", "Reports", new {area = "Configurations", id = @Model.Patient.Person.AuthorId, body = detalle, description = "Certificado Medico"})" ) ;
//// var win = window.open('http://stackoverflow.com/', '_blank');
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
}
});
Upvotes: 3
Views: 972
Reputation: 628
I recomend you to use specific report for each case, you can do it dinamically, but, just one for each type of it, because all of them, have diferent sizes
Upvotes: 1
Reputation: 8736
Problem is that you passing JS variable into Url.Action In your case, you should do like that:
$('#BtnPrint').click(function() {
var detalle = "<br><br>";
detalle += " Yo: <b>" + '@Model.DoctorText' + "</b>";
if ('@Model.Exequartur' != "") {
detalle += ", exequatur: <b>" + '@Model.Exequartur' + "</b> <br>";
}
detalle += " certifico haber examinado a: <b>" + '@Model.PatientName' + "</b> <br>";
@*if (@Model.ide != "")
{
detalle += " cedula: <b>" + txtcedula.Text + "</b> <br>";
}*@
detalle += " quien presenta: <b>" + '@Model.Affections' + "</b> <br>";
detalle += " por lo que recomiendo: <b>" + '@Model.Recomendations' + "</b> <br>";
detalle += "<br> dado en: <b>" + ' @Model.Place' + "</b>, " + '@Model.MedicalCertificateDate' +
" <br>";
detalle += "<br><br><br><br> ";
$('#myVar').val(detalle);
var url = '@Url.Action("DetailsPrint", "Reports", new {area = "Configurations", id = @Model.Patient.Person.AuthorId, description = "Certificado Medico"})';
url = url + "&body="+encodeURIComponent(detalle);
var win = window.open(url);
//// var win = window.open('http://stackoverflow.com/', '_blank');
if (win) {
//Browser has allowed it to be opened
win.focus();
} else {
//Browser has blocked it
alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
}
});
And your controller should be:
[ValidateInput(false)]
public ActionResult DetailsPrint(string body, int id, string description)
{
//something
}
Upvotes: 1