我在页面上有一个带有gridview的模态窗口,在gridview的buttonField中是GridViewCommandEventArgs的方法,其响应是这样的,但是BinnaryWrite无法正常工作。 我的想法...在模式对话框中,单击gridview行中的按钮,然后response.binarywrite将数据发送到客户端浏览器。
string attachement = context.Items["attachement"].ToString();
string extension = context.Items["extension"].ToString();
//errorText = runComment;
byte[] attach = Convert.FromBase64String(attachement);
context.Response.Clear();
string MimeTypeContentType = MimeMapping.GetMimeMapping("aa." + extension);
context.Response.ContentType = MimeTypeContentType;
context.Response.AppendHeader("Content-Disposition", "inline;filename=priloha_" + DateTime.Now.Ticks.ToString() + ".pdf");
context.Response.BufferOutput = true;
context.Response.BinaryWrite(attach);
context.Response.End();
Blockquote ×
<asp:BoundField HeaderText="Veľkosť (MB)" DataField="size" SortExpression="size" ItemStyle-VerticalAlign="Middle">
<ItemStyle VerticalAlign="Middle"></ItemStyle>
</asp:BoundField>
<asp:BoundField HeaderText="subjectNumber" DataField="subjectNumber" SortExpression="subjectNumber" ItemStyle-VerticalAlign="Middle">
<ItemStyle VerticalAlign="Middle"></ItemStyle>
</asp:BoundField>
<asp:ButtonField Text="Otvoriť »" ItemStyle-VerticalAlign="Middle" runat="server">
<ControlStyle CssClass="btn btn-primary" />
<ItemStyle VerticalAlign="Middle"></ItemStyle>
</asp:ButtonField>
</Columns>
</asp:GridView>
</div>
<div class="modal-footer">
<button class="btn btn-primary" data-dismiss="modal" aria-hidden="true">Zavrieť</button>
</div>
</div>