publicstringexcelPath在页面加载之前声明。在执行时赋值protectedvoidButtonOK_Click(objectsender,EventArgse){//HttpPostedFileFIlE=FileUploadstringpath=this.ExcelPath.PostedFile.FileName;Session.Add(path,ExcelPath.FileName);excelPath=Session["path"].ToString();}