• 让Updatepanel中的控件触发整个页面Postback


    GridView被Updatepanel包起来了,但是GridView上有一个Download的ImageButton, 局部刷新的话,无法下载文件, 所以用下面代码注册updatepanel中的download button每次点击都整个页面postback。
    for (int i = 0; i < this.GridViewSOPDocument.Rows.Count; i++)
                {
                    ImageButton imageButtonDownload 
    = (ImageButton)this.GridViewSOPDocument.Rows[i].FindControl("ImageButtonDownload");
                    
    if (imageButtonDownload != null)
                    {
                        ((ScriptManager)((VPJQueryMaster)
    this.Master).FindControl("ScriptManager1")).RegisterPostBackControl(imageButtonDownload);
                    }
                }

    Download方法:
    public void FileDownload(string filePath, string fileName, string systemFileName)
            {
                FileInfo DownloadFile
                        
    = new FileInfo(this.ApplicationPhysicalPath + filePath + "\\" + systemFileName);
                
    if (DownloadFile.Exists)
                {
                    Response.Clear();
                    Response.ClearHeaders();
                    Response.Buffer 
    = false;
                    Response.ContentType 
    = "application/octet-stream";
                    Response.AppendHeader(
    "Content-Disposition""attachment;filename="
                        
    + HttpUtility.UrlDecode(fileName, System.Text.Encoding.UTF8));
                    Response.AppendHeader(
    "Content-Length", DownloadFile.Length.ToString());
                    Response.WriteFile(DownloadFile.FullName);
                    Response.Flush();
                    Response.End();
                }
                
    else
                {
                    ShowAjaxMessage(
    "msg_public_download_file_does_not_exist");
                }
            }
  • 相关阅读:
    函数
    vue中v-for循环如何将变量带入class的属性名中
    代码规范 前端导航
    2019.8.5 mysql 删除 更新
    2019.8.1
    2019.7.31 Xshell简单学习
    日常使用知识点
    FormData实现文件多次添加累加上传和选择删除
    上传图片
    验证码
  • 原文地址:https://www.cnblogs.com/songsh96/p/1529999.html
Copyright © 2020-2023  润新知