<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<head>
<script language="VB" runat="server">
	public property ReplaceName() as string'旧文件名
		get
			return ViewState("ReplaceName").ToString()
		end get
		set
			ViewState("ReplaceName")=value
		end set
	end property
	public property UpPath() as string'目前上传路径
		get
			return ViewState("UpPath").ToString()
		end get
		set
			ViewState("UpPath")=value
		end set
	end property
	public readOnly property OKFile() as string'上传后的文件名
		get
			return NowF.Text
		end get
	end property
	sub ExecUpload(sender as object,e as EventArgs)'执行上传
		Dim FN as string=""
		Dim x as string=UpFile.PostedFile.FileName
		if x <>"" then
			dim y as integer  = x.LastIndexOf("\")
			FN = x.Remove(0,y+1)
			try'上传
				UpFile.PostedFile.SaveAs(UpPath + "\" + FN)
				UpFileName.Text=FN'显示在更改为
			catch
				errLabel.Visible = true
				errLabel.Text="发生错误，无法上传"
			end try
		end if
	end sub
	public sub Show()
		UploadFile.Visible=true
	end sub
	sub OK_Click(sender as object,e as EventArgs)'OK
		if UpFileName.Text<>"" then
			NowF.Text=UpFileName.Text
		end if
		UploadFile.Visible=false
		ShowUp.Visible=true
	end sub
	sub CelClick(sender as object,e as EventArgs )'取消
		UploadFile.Visible=false
		ShowUp.Visible=true	
	end sub
	sub ShowUp_Click(sender as object,e as EventArgs )
		UploadFile.Visible=true
		ShowUp.Visible=false
	end sub
</script>
目前文件：<ASp:Label id="NowF" Text='<%# ReplaceName %>' Runat="server" /><asp:linkButton text="显示上传" onclick="ShowUp_Click" runat="server" id="ShowUp" visible="false" /><br>
<asp:Panel id="UploadFile" borderstyle=Outset runat="server" Height="60px" Width="250px" BorderWidth="3">
更改为：<asp:label id="UpFileName" runat="server" /><br>
	指定上传文件：
	<input id="UpFile" type=file runat="server" size="20"><br>
	<asp:linkButton id="Button2" text="Upload" OnClick="ExecUpload" runat="server" />　
	<asp:linkButton id="Button3" text="OK" OnClick="OK_Click" runat="server" />　
	<asp:linkButton  text="Cancel" Onclick="CelClick" ID="cel1" Runat="server" />
	<br><asp:Label id=errLabel visible=true runat="server"></asp:Label>
</asp:Panel>