0

Webページでは、いくつかのデータフィールドに入力し、ddlからpdfタイプを選択した後、ユーザーがpdfファイルをダウンロード/表示できるため、すべてのコンポーネントの後にエラーリピーターがあり、エラーが表示され、値をクリアできないという問題があります、ポストバックが発生しないためです。そのため、PDF を印刷する前にミスがあった場合、そのミスはリピーターに残り、それを削除することはできません。ファイルのダウンロードウィンドウが表示されたときにポストバックがないため...

日付テキストボックス

日付テキストボックス

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();
            }
        }

これまでのところ唯一の解決策は、検証 (ontextchange イベントを dataTextBoxe に追加...) を buttonClick イベントの外側の関数に移動することです。間違いがない場合は、buttonClick で pdf を印刷します。

あなたが助けてくれることを願っています

貪欲

4

0 に答える 0