Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.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
ASP.NETC#文件下载窗口停止回发,错误消息保留在中继器中_C#_Asp.net_Repeater - Fatal编程技术网

ASP.NETC#文件下载窗口停止回发,错误消息保留在中继器中

ASP.NETC#文件下载窗口停止回发,错误消息保留在中继器中,c#,asp.net,repeater,C#,Asp.net,Repeater,网页允许用户在填充一些数据字段并从ddl中选择pdf类型后下载/查看pdf文件,因此我遇到的问题是,在所有组件之后都有一个错误重发器,它显示错误,我无法清除值,因为回发不会发生。 所以,若我在打印PDF之前犯了一个错误,那个么这个错误将留在repeater中,并且不可能删除它。因为文件下载窗口出现时没有回发 日期文本框 日期文本框 ddl 钮扣 错误转发器 protected void btnPrintPDF(object sender, EventArgs e) {

网页允许用户在填充一些数据字段并从ddl中选择pdf类型后下载/查看pdf文件,因此我遇到的问题是,在所有组件之后都有一个错误重发器,它显示错误,我无法清除值,因为回发不会发生。 所以,若我在打印PDF之前犯了一个错误,那个么这个错误将留在repeater中,并且不可能删除它。因为文件下载窗口出现时没有回发

日期文本框

日期文本框

ddl

钮扣

错误转发器

  protected void btnPrintPDF(object sender, EventArgs e)
        {

       if(DateTextbox'es !valid)
       {
          errors.add(new error);
       }
       if(ddl!selected)
       {
          errors.add(new error);
       }

       if(error.count==0){
         errors=null; //so if we had any errors before in the repeater,  
         errorRepeater=errors;//they Stay there and you can't delete them
         errorRepeater.databind();

         print.pdf(); //a download window jumps in browser killing postback
         //manually calling js postback from Codebehind doesn't work
}

protected void print.pdf(MemoryStream ms, string pdfName, string xslName)
        {
            ResourceContext xsltSert = new ResourceContext("/Path/xsl/" + xslName);
            Stream pdf;
            xsltSert.generatePdf(xmlInputStream: ms, pdf: out pdf);
            try
            {
                Response.ContentType = "application/pdf";
                HttpUtils.httpStream(Response, pdf, pdfName);
                Response.Close();
            }
            finally
            {
                pdf.Close();
            }
        }
到目前为止,唯一的解决方案是将验证(将ContextChange事件添加到dataTextBoxe的…)移动到buttonClick事件之外的函数,如果没有错误,则以lame方式在buttonClick print pdf中

希望你能帮忙


greed

回发是将数据发送回服务器的过程,这是正确的。调用print.pdf时,将修改发送到web浏览器的返回数据。但是我们对print.pdf一无所知。你在用什么库?@Adam更新了库,或者编写了打印程序