我通过imageurl="showphoto.aspx?id="+id,能正常显示,但图片变形了,怎么在我的基础上缩略显示
showphoto.aspx:如下
private void Page_Load(object sender, System.EventArgs e)
{
string id=Request.QueryString["Id"].ToString();
string sql="SELECT * FROM Product WHERE ID = " + id;
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection();
sqlConnection.ConnectionString = ((string)(configurationAppSettings.GetValue("ConnectionString", typeof(string))));
SqlCommand command = new SqlCommand(sql,sqlConnection);
sqlConnection.Open();
SqlDataReader dr = command.ExecuteReader();
if(dr.Read())
{
Response.Clear();
Response.AddHeader("Content-Type",dr["pFileType"].ToString());
Response.BinaryWrite((byte[])dr["Picture"]);
}
dr.Close();
sqlConnection.Close()
showphoto.aspx:如下
private void Page_Load(object sender, System.EventArgs e)
{
string id=Request.QueryString["Id"].ToString();
string sql="SELECT * FROM Product WHERE ID = " + id;
System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection();
sqlConnection.ConnectionString = ((string)(configurationAppSettings.GetValue("ConnectionString", typeof(string))));
SqlCommand command = new SqlCommand(sql,sqlConnection);
sqlConnection.Open();
SqlDataReader dr = command.ExecuteReader();
if(dr.Read())
{
Response.Clear();
Response.AddHeader("Content-Type",dr["pFileType"].ToString());
Response.BinaryWrite((byte[])dr["Picture"]);
}
dr.Close();
sqlConnection.Close()
解决方案 »
- System.Data.SqlServerCe(windows ce编程)
- WPF中ListBoxItem问题~~急~~
- 线程操作中我要是给函数传参怎么办?
- 递归运算,计算无法处理,老是未响应,找人帮忙。
- 关于C#数据库连接的问题
- 请问怎么样给其它控件加一个ReadOnly属性,就像Textbox控件的ReadOnly属性实现一样的功能
- 如何得到tcpListener.AcceptTcpClient()之后的IP地址?
- 有志于自己做出点东西,又不满足于上班,希望自己创业,又没有合作团队的南京程序员进来!!!!!(其它地方也可以)!!!!
- 这段英文可能提高很多人的层次 ... ... ,请大家探讨其中味道!!
- System.Web求救!!!
- DataGrid的按钮列里的编辑、更新、取消,更新时的编辑框宽度怎么设置???
- 关于组合查询的问题,小弟求救啊。谢谢哥哥帮帮我啊!
{
//将原始图片缩放为指定大小的图片
System.Drawing.Bitmap b = new System.Drawing.Bitmap(Server.MapPath(strFileName));
if(b.Width > maxWidth)
{
if(nHeight < 1) nHeight = b.Height; Bitmap result = new Bitmap(nWidth,nHeight);
Graphics g = Graphics.FromImage((System.Drawing.Image)result);
g.DrawImage(b,0,0,nWidth,nHeight);
int index=strFileName.LastIndexOf("/");
string strForeside="";
if(index>0) strForeside=strFileName.Substring(0,index+1);
strFileName = strForeside+"Temp"+strFileName.Substring(strFileName.Length-4); result.Save(Server.MapPath(strFileName)); result.Dispose();
g.Dispose();
}
b.Dispose(); return strFileName;
}
<asp:Image id=Image3 runat="server" ImageUrl='<%#DataBinder.Eval(Container, "DataItem.字段名")%>'</asp:Image></ItemTemplate>
这么久的帖子都给翻了出来, hoho