首页
最近更新
热门教程
ASP.NET
开发语言
开发环境
AJax教程
控件开发
统计报表
数据库
Web服务
安装部署
HTML教程
Javascript
XML教程
Community Server
NHibernate
书籍推荐
常用工具
实用代码
教程全文搜索
首页
>>
byang的知识库
>>
Asp.net
获取图片长度和宽度代码
添加人:
byang
添加时间:2007-08-24 阅读次数:1448
收藏此教程
1
using
System;
2
using
System.Collections;
3
using
System.ComponentModel;
4
using
System.Data;
5
using
System.Drawing;
6
using
System.Web;
7
using
System.Web.SessionState;
8
using
System.Web.UI;
9
using
System.Web.UI.WebControls;
10
using
System.Web.UI.HtmlControls;
11
12
namespace
CommonFunction
13
{
14
/**/
///
<summary>
15
///
ImageSize 的摘要说明。
16
///
</summary>
17
public
class
ImageSize : System.Web.UI.Page
18
{
19
protected
System.Web.UI.WebControls.Label Label1;
20
protected
System.Web.UI.HtmlControls.HtmlInputFile upImage;
21
protected
System.Web.UI.WebControls.TextBox txtHeight;
22
protected
System.Web.UI.WebControls.Label Label2;
23
protected
System.Web.UI.WebControls.Label Label3;
24
protected
System.Web.UI.WebControls.TextBox txtWidth;
25
protected
System.Web.UI.WebControls.Button btnGet;
26
27
protected
string
imgPath;
28
protected
string
fileExtName;
29
30
private
void
Page_Load(
object
sender, System.EventArgs e)
31
{
32
//
在此处放置用户代码以初始化页面
33
}
34
35
Web Form Designer generated code
#region
Web Form Designer generated code
36
override
protected
void
OnInit(EventArgs e)
37
{
38
//
39
//
CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
40
//
41
InitializeComponent();
42
base
.OnInit(e);
43
}
44
45
/**/
///
<summary>
46
///
设计器支持所需的方法 - 不要使用代码编辑器修改
47
///
此方法的内容。
48
///
</summary>
49
private
void
InitializeComponent()
50
{
51
this
.btnGet.Click
+=
new
System.EventHandler(
this
.btnGet_Click);
52
this
.Load
+=
new
System.EventHandler(
this
.Page_Load);
53
54
}
55
#endregion
56
57
private
void
btnGet_Click(
object
sender, System.EventArgs e)
58
{
59
if
(upImage.PostedFile.FileName
!=
""
)
60
{
61
imgPath
=
upImage.PostedFile.FileName;
62
fileExtName
=
imgPath.Substring(imgPath.LastIndexOf(
"
.
"
)
+
1
,
3
);
63
64
if
(fileExtName
!=
"
gif
"
&&
fileExtName
!=
"
jpg
"
)
65
{
66
Response.Write(
"
请选择GIF和JPG格式的图片
"
);
67
}
68
else
69
{
70
System.Drawing.Image image
=
System.Drawing.Image.FromFile(imgPath);
71
txtHeight.Text
=
image.Height.ToString();
72
txtWidth.Text
=
image.Width.ToString();
73
}
74
}
75
else
76
{
77
Response.Write(
"
请选择图片!
"
);
78
}
79
}
80
}
81
}
82
共
1
页 第
1
页
上一页
1
下一页
相关的教程:
入门
Asp.Net2.0
收藏此教程
Currently.-0.05/5
-5
-4
-3
-2
-1
0
1
2
3
4
5
当前平均分:
0.0
(
0
次打分)
-5
-4
-3
-2
-1
0
1
2
3
4
5
推荐阅读
从零开始学ASP.NET(基础篇)
ASP.NET 2.0轻松实现数据库应用开发
NHibernate 系列研究
ASP.NET2.0的页生命周期
ASP.NET 2.0 中的资源与本地化
ASP.NET2.0的页生命周期
asp.net 局域网存放文件
用Split()方法提取字符
Visual C# 2005快速入门之编写方法
C#积木模块ABC:16.使用系统剪贴板
添加评论
评论主题
您的大名
您的评论
验证码
评论列表
ASP.NET论坛
|
网站帮助
|
加入收藏
知识库搜索:
用户信息
欢迎您,游客。
登录
|
注册
为什么要注册?
马上加入GotAspx,建立自己的知识库,与大家分享您的知识库,还可获得丰厚积分奖励!
最新文章
JavaScript 的面向对象编程的原型概念
获取图片长度和宽度代码
热门文章
获取图片长度和宽度代码
JavaScript 的面向对象编程的原型概念