ModalPopup에서 파일 다운로드를위한 (비즈니스 규칙 기반) 파일 이름을 제안하는 특정 동작을 찾고 있습니다. 파일 보내기 후 ModelPopup 닫기
사용자가 [확인]을 클릭하면
는 파일이 다운로드되며, 팝업 닫아야합니다. 취소하면 방금 닫힙니다. 이 모든 뒤에 코드에 의해 구동 :protected void ExportPromptOkButton_Clicked(object sender, EventArgs e)
{
string path = MapPath(ExportPromptPanelFileName.Text);
WriteExport(path);
ExportPromptModalPopupExtender.Hide();
this.SendFile(path, "text/plain");
}
//...
public static void SendFile(this Page webPage, string filepath, string contenttype)
{
webPage.Response.AddHeader("Content-disposition", "attachment; filename=" + Path.GetFileName(filepath));
webPage.Response.ContentType = contenttype;
webPage.Response.WriteFile(filepath);;
webPage.Response.End();
}
문제는 Response.End();
모든 조치를 (물론, 예상대로) 죽이고, 그래서 모달 창 자체가 닫히지 않습니다 것입니다.
올바른 접근 방법은 무엇입니까? iframe을 사용하여 파일을 보내려는 Response
을 호출하려고했지만 이것이 적절한 지 또는 더 나은 것이 있는지 확인하고 싶습니다.
ASPX 선언 : ModalPopup에
을 같이
<ajaxToolkit:ModalPopupExtender
runat="server"
ID="ExportPromptModalPopupExtender"
BackgroundCssClass="modalBackground"
TargetControlID="ExportButton"
PopupControlID="ExportPromptPanel"
PopupDragHandleControlID="ExportPromptPanelHeader"
CancelControlID="ExportPromptCancelButton"
Drag="true">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="ExportPromptPanel" runat="server" CssClass="popupConfirmation" style="display: none;">
<div class="popupContainer" style="width:300px">
<div class="popupHeader" id="ExportPromptPanelHeader">
<div class="popupHeaderLeft">Export</div><div class="popupHeaderRight"></div>
</div>
<div class="popupBody">Export under the following name:<br />
<asp:TextBox ID="ExportPromptPanelFileName" runat="server" MaxLength="60" Width="230px"></asp:TextBox></div><div class="popupButtons">
<asp:Button ID="ExportPromptOkButton" runat="server" Text="Ok" OnClick="ExportPromptOkButton_Clicked" />
<asp:Button ID="ExportPromptCancelButton" runat="server" Text="Cancel" />
</div>
</div>
</asp:Panel>
제게는 효과가 있습니다 .. 고마워요. :) – Syed