常用代码
1: 不想让用户直接在IE中打开已知类型的的文件,直接下载
string FullName = "works.gif";
Response.AddHeader("Content-Disposition", "attachment;filename=" + FullName);
Response.AddHeader("Content-Length", FullName.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(FullName);
Response.End();
2:动态添加用户控件:
添加一个PlaceHolder 控件<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
在后台添加代码
System.Web.UI.UserControl uc = (System.Web.UI.UserControl)LoadControl("Control/uc2.ascx");
PlaceHolder1.Controls.Add(uc);
Response.AddHeader("Content-Disposition", "attachment;filename=" + FullName);
Response.AddHeader("Content-Length", FullName.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(FullName);
Response.End();
2:动态添加用户控件:
添加一个PlaceHolder 控件<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
在后台添加代码
System.Web.UI.UserControl uc = (System.Web.UI.UserControl)LoadControl("Control/uc2.ascx");
PlaceHolder1.Controls.Add(uc);
lemon

浙公网安备 33010602011771号