0

更新パネルがあり、その中に ajax updateprogress、ラジオ ボタン、FileUpload コントロールなどの多くのコントロールを配置しました。最後に 2 つのボタンがあります。1 つはデータを保存するボタン、もう 1 つは xml データを生成するボタンです。

xml を生成している間、次のコードで画面にストリーミングしています。

 Response.Clear();
 Response.ClearContent();
 Response.ClearHeaders();
 Response.ContentType = "application/xml";
 Response.AddHeader("Content-Disposition", "attachment; filename=" + filePath);
 Response.TransmitFile(filePath);
 Response.End();

この時点では、更新の進行状況の画像は閉じられていません。誰でも私を助けることができますか?

4

1 に答える 1

0

ファイルがクライアントに送信されると、応答が終了するためです。新しいページでそれを行う必要があります。

ページで、次のコードを置き換えます。

Session["filePath"] = filePath;
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'file.aspx', null, 'height=700,width=760,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);

新しいページ (「file.aspx」と呼ばれる):

protected void Page_Load(object sender, EventArgs e)
{
     Response.Clear();
     Response.ClearContent();
     Response.ClearHeaders();
     Response.ContentType = "application/xml";
     Response.AddHeader("Content-Disposition", "attachment; filename=" +  Session["filePath"].ToString());
     Response.TransmitFile(Session["filePath"].ToString());
     Response.End();
}
于 2013-06-10T11:05:43.343 に答える