<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<head>
<script language="C#" runat="server">
	public string ReplaceName{//旧文件名
		get{
			return ViewState["ReplaceName"].ToString();
		}
		set{
			ViewState["ReplaceName"]=value;
		}
	}
	public string UpPath{//目前上传路径
		get{
			return ViewState["UpPath"].ToString();
		}
		set{
			ViewState["UpPath"]=value;
		}
	}
	public string OKFile{//上传后的文件名
		get{
			return NowF.Text;
		}
	}
	void ExecUpload(object sender,EventArgs e){//执行上传
		string FN="";
		string x=UpFile.PostedFile.FileName;
		if(x!=""){
			int y = x.LastIndexOf("\\");
			FN = x.Remove(0,y+1);
			try{//上传
				UpFile.PostedFile.SaveAs(UpPath + "\\" + FN);
				UpFileName.Text=FN;//显示在更改为
			}
			catch(Exception u){
				errLabel.Visible = true;
				errLabel.Text="发生错误，无法上传";
			}
		}
	}
	public void Show(){
		UploadFile.Visible=true;
	}
	void OK_Click(Object sender,EventArgs e){//OK
		if(UpFileName.Text!=""){
			NowF.Text=UpFileName.Text;
		}
		UploadFile.Visible=false;
		ShowUp.Visible=true;
	}
	void CelClick(object sender,EventArgs e){//取消
		UploadFile.Visible=false;
		ShowUp.Visible=true;	
	}
	void ShowUp_Click(Object sender,EventArgs e){
		UploadFile.Visible=true;
		ShowUp.Visible=false;
	}
</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>