using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Data.SqlClient; using System.Drawing; using System.Drawing.Imaging; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; namespace TipsTricks.Ch4 { /**////<summary> /// Summary description for ShowSmallImage. ///</summary> publicclass ShowSmallImage : System.Web.UI.Page { constint MaxLength=150; //最大长度 privatevoid Page_Load(object sender, System.EventArgs e) { if (Request.QueryString["filename"] !=null) { //取得原图 string filename=Request.QueryString["filename"]; Bitmap bmpOld=new Bitmap(Server.MapPath("images/"+ filename)); //计算缩小比例 double d1; if (bmpOld.Height>bmpOld.Width) d1=(double)(MaxLength/(double)bmpOld.Width); else d1=(double)(MaxLength/(double)bmpOld.Height); //产生缩图 Bitmap bmpThumb=new Bitmap(bmpOld,(int)(bmpOld.Width*d1),(int)(bmpOld.Height*d1)); // 清除缓冲 Response.Clear(); //生成图片 bmpThumb.Save(Response.OutputStream, ImageFormat.Jpeg); Response.End(); //释放资源 bmpThumb.Dispose(); bmpOld.Dispose(); } } Web Form Designer generated code#region Web Form Designer generated code overrideprotectedvoid OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /**////<summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///</summary> privatevoid InitializeComponent() { this.Load +=new System.EventHandler(this.Page_Load); } #endregion } }
using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.IO; namespace TipsTricks.Ch4 { /**////<summary> /// Summary description for ListImage. ///</summary> publicclass ListImage : System.Web.UI.Page { protected System.Web.UI.WebControls.DataList DataList1; privatevoid Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { //获取文件名称 string[] files=Directory.GetFiles(Server.MapPath("images")); //建立数据表 DataTable dt=new DataTable(); dt.Columns.Add("filename"); dt.Columns.Add("size"); foreach (string s in files) { DataRow dr=dt.NewRow(); FileInfo f=new FileInfo(s); dr["filename"]=f.Name; dr["size"]=f.Length; dt.Rows.Add(dr); } //绑定显示 this.DataList1.DataSource=dt; this.DataList1.DataBind(); } } publicvoid HHH(object sender, System.EventArgs e) { this.Response.Write("hello"); } Web Form Designer generated code#region Web Form Designer generated code overrideprotectedvoid OnInit(EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); base.OnInit(e); } /**////<summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. ///</summary> privatevoid InitializeComponent() { this.Load +=new System.EventHandler(this.Page_Load); } #endregion } }
以上为调用页面...
posted on
2005-05-12 08:44gwazy
阅读(1562)
评论(1)
编辑收藏举报