页面代码
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication5.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
    
<HEAD>
        
<title>WebForm1</title>
        
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
        
<meta name="CODE_LANGUAGE" Content="C#">
        
<meta name="vs_defaultClientScript" content="JavaScript">
        
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    
</HEAD>
    
<body MS_POSITIONING="GridLayout">
        
<form id="Form1" method="post" runat="server" enctype="multipart/form-data">
            
<TABLE id="Table1" cellSpacing="0" borderColorDark="#000000" cellPadding="0" width="800"
                align
="center" borderColorLight="darkgray" border="0">
                
<TR>
                    
<TD colSpan="3">
                        
<TABLE id="Table2" cellSpacing="0" cellPadding="0" width="100%" border="0">
                            
<TR>
                                
<TD colSpan="3">
                                
</TD>
                            
</TR>
                            
<TR>
                                
<TD bgColor="whitesmoke" colSpan="3">
                                    
<P><INPUT class="s_verdana" type="file" size="40" name="m_file" ContentEditable="false">
                                        
<asp:Button id="Button1" runat="server" Text="Upload" CssClass="s_verdana"></asp:Button></P>
                                    
<P>
                                        
<asp:Label id="Label1" runat="server"></asp:Label></P>
                                
</TD>
                            
</TR>
                        
</TABLE>
                    
</TD>
                
</TR>
            
</TABLE>
        
</form>
    
</body>
</HTML>

c#

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 Webb.WAVE.Controls.Upload;
using System.IO;

namespace WebApplication5
{
    
/// <summary>
    
/// WebForm1 的摘要说明。
    
/// </summary>

    public class WebForm1 : System.Web.UI.Page
    
{
        
protected System.Web.UI.WebControls.Button Button1;
        
protected System.Web.UI.WebControls.Label Label1;
    
        
private void Page_Load(object sender, System.EventArgs e)
        
{
            
// 在此处放置用户代码以初始化页面
        }


        
private void Button1_Load(object sender, System.EventArgs e)
        
{
            Button    m_button        
= sender as Button;
            WebbUpload m_upload        
= new WebbUpload();
            m_upload.RegisterProgressBar(m_button);
        }


        
private void Button1_Click(object sender, System.EventArgs e)
        
{
            
string m_path            = Path.Combine(MapPath("."),"UploadedFiles");
            WebbUpload m_upload        
= new WebbUpload();
            UploadFile m_file        
= m_upload.GetUploadFile("m_file");
            
string m_filePath        = Path.Combine(m_path,Path.GetFileName(m_file.ClientFullPathName));
            m_file.SaveAs(m_filePath);
            
this.Label1.Text        = "Uploaded file:<br/>";
            
this.Label1.Text        += "<a href='uploadedFiles\\"+Path.GetFileName(m_file.ClientFullPathName)+"'>uploadedFiles\\"+Path.GetFileName(m_file.ClientFullPathName)+"</a><p>";
        }


        
Web 窗体设计器生成的代码




    }

}


上传控件
posted on 2006-12-11 11:16  我爱写sql  阅读(175)  评论(0)    收藏  举报