public partial class _Default : Page { private string strFile = HttpContext.Current.Server.MapPath("~/Output/"); private string strUpload = HttpContext.Current.Server.MapPath("~/Data/"); private string strOutput = "" + DateTime.Now.ToString("ddMMyyy_hhmmss") + ".xls"; private ReadExcel readExcel = new ReadExcel(); private ExcelData excelData; private string sFileName; protected void Page_Load(object sender, EventArgs e) { excelData = new ExcelData(); sFileName = string.Empty; } protected void btnUpload_Click(object sender, EventArgs e) { if ((fileUploadDialog.PostedFile != null) && (fileUploadDialog.PostedFile.ContentLength > 0)) { string fn = Path.GetFileName(fileUploadDialog.PostedFile.FileName); excelData.fileName = fn; sFileName = fn; string saveLocation = strUpload + "\\" + fn; try { fileUploadDialog.PostedFile.SaveAs(saveLocation); // Response.Write(""); lblStatus.Text = "Upload Status: The file has been uploaded. " + excelData.fileName ; } catch (Exception ex) { Response.Write(ex); } } else { lblStatus.Text = "Please select a file to upload"; } } protected void btnDisplay_Click(object sender, EventArgs e) { lblStatus.Text = "test" + sFileName ; //bothe sFileName and excelData.fileName will return null Why? //DataTable dt = readExcel.readCutomManualID(excelData.fileName); } } }
namespace TGSTax.Models { public class ExcelData { // public string fileName { get; set; } string _fileName; public string fileName { get { return this._fileName; } set { this._fileName = value; } } //public ExcelData() //{ // public string fileName { get; set; } //} } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)