Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/387.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Html作为参数从javascript发送到asp.net mvc控制器_Javascript_Jquery_Html_Asp.net Mvc - Fatal编程技术网

将Html作为参数从javascript发送到asp.net mvc控制器

将Html作为参数从javascript发送到asp.net mvc控制器,javascript,jquery,html,asp.net-mvc,Javascript,Jquery,Html,Asp.net Mvc,我需要使用jquery将一些HTML标记传递给控制器(请查看我的detalle变量),操作中是我在尝试发送detalle时遇到问题,它说找不到,有人可以帮我吗 $('#BtnPrint').click(function() { var detalle = "<br><br>"; detalle += " Yo: <b>" + '@Model.DoctorText' + "

我需要使用jquery将一些HTML标记传递给控制器(请查看我的detalle变量),操作中是我在尝试发送detalle时遇到问题,它说找不到,有人可以帮我吗

           $('#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 :'( ");
                }

            });
$('#BtnPrint')。单击(函数(){
var detalle=“

”; detalle+=“Yo:”+'@Model.doctorext'+'”; 如果('@Model.execquartur'!=“”){ detalle+=”,exequatur:“+'@Model.Exequartur'+”
”; } detalle+=“哈伯考试证书a:”+'@Model.PatientName'+“
”; @*如果(@Model.ide!=“”) { detalle+=“cedula:”+txcedula.Text+“
”; }*@ detalle+=“quien presenta:”+'@Model.affects'+“
”; detalle+=“por lo que recomiendo:”+'@Model.Recomendations'+“
”; detalle+=“
护墙板en:“+'@Model.Place'+”,“+'@Model.MedicalCertificateDate”+ “
”; detalle+=“



”; $('#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/","空白",; 如果(赢){ //浏览器已允许将其打开 win.focus(); }否则{ //浏览器已阻止它 警报(“请注意,报告编号为va a salir:”(“”); } });
问题在于将JS变量传递到Url.Action中 在您的情况下,您应该这样做:

$('#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 :'( ");
    }

});

我建议您对每种情况使用特定的报告,您可以通过友好的方式进行,但是,对于每种类型,只使用一个报告,因为所有报告都有不同的大小

当我尝试时,在中的第402行第43列出现此错误
JavaScript严重错误http://localhost:13076/Medicals/Patients/DetailsMedicalCertificates/1\n\nSCRIPT5017:语法错误在正则表达式中
我已经修复了我的答案谢谢,它解决了问题,但是,现在我有了另一个,在视图上没有呈现html,你知道会发生什么吗?视图显示如下*

Yo:Pepe,exequatur:3333
certifico haber-examiado a:Lala*这是我在视图
@ViewBag.MyBody
上的html需要使用
@Html.Raw(ViewBag.MyBody)
优秀的人,我不知道如果世界上没有像你这样的人,我会发生什么,太感谢了:我确实需要这样做,因为我不可能把它当作一个普通的报告,谢谢兄弟,欢迎来到stackoverflow
[ValidateInput(false)]
public ActionResult DetailsPrint(string body, int id, string description)
{
    //something
}