您现在的位置: 无忧电子商务网 >> 信息学院 >> 程序开发 >> asp.net >> 正文

在ASP.NET里轻松实现缩略图

作者:作者:未…    信息学院来源:网络收集    点击数:    更新时间:2006-8-28 我要参与讨论

  以前,在页面上实现缩略图必须借助第三方组件。现在,有了.NET,就可以很轻松地实现缩略图。下面就是实现缩略图的例子。

查看例子

代码如下:Thumbnail.aspx

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Thumbnail.aspx.vb"
Inherits="aspxWeb.Thumbnail" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>在ASP.NET里轻松实现缩略图</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="javascript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<asp:Label id="Label1" runat="server"></asp:Label>
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
<INPUT type="file" name="file" width="600"><br><br>
<asp:Button id="Button1" runat="server"></asp:Button>
</form>
</body>
</HTML>

后代码:Thumbnail.aspx.vb

Imports System
Imports System.Web
Imports System.Drawing
Imports System.IO
Imports System.Drawing.Imaging

Public Class Thumbnail
Inherits System.Web.UI.Page
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Button1 As System.Web.UI.WebControls.Button

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label1.Text = "<h3>在ASP.NET里轻松实现缩略图</h3>"
Button1.Text = "上载并显示缩略图"
End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyFileColl As HttpFileCollection = HttpContext.Current.Request.Files
Dim MyPostedFile As HttpPostedFile = MyFileColl.Item(0)
If LCase(MyPostedFile.ContentType.ToString()).IndexOf("image") < 0 Then
Response.Write("无效的图形格式。")
Ex

[1] [2] [3] [4] 下一页

在google里搜索更多在ASP.NET里轻松实现缩略图

Google
Web www.51ec.org
  • 上一篇信息学院:

  • 下一篇信息学院:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    我来说两句 对此文章发表了评论
      昵 称: *必填    ·注册用户·
      评 分: 1分 2分 3分 4分 5分     严禁发表危害国家安全、政治、黄色淫秽等内容的评论,用户需对自己在使用本网站服务过程中的行为承担法律责任。本站管理员有权保留或删除评论内容,评论内容只代表机友个人观点,与本网站立场无关。  
    评 论
    内 容

     
    评论列表 (最新 评论仅限网友观点!)

    供求信息




    | 设为首页 | 加入收藏 | 关于我们 | 广告服务 | 联系方式 | 友情链接 | 版权申明