单击后加载文件并填充页面

时间:2015-11-02 15:09:27

标签: c# asp.net

我有一个简单的请求。我有这个:

enter image description here

所以,在我的.aspx:

<asp:FileUpload ID="myFileUpload" runat="server" onclick="LoadFile_Click" />

在按下“加载文件”按钮后,我希望页面将填充所选文档的数据。像这样:

enter image description here

在我的.aspx.cs

    protected void LoadFile_Click(Object sender, EventArgs e)
    {
        string address = // a way to get the path of the file. How?
        BindExcelToPage(address); // this method fills the web page with the data taken from the file uploaded;
    }
  • 信息性短语“无文件选择”(或其他)必须是不可见的。我只想加载按钮。
  • 我不知道如何实现加载页面的事件的开始。

1 个答案:

答案 0 :(得分:0)

使用页面绑定BindExcel文件后,隐藏文件上载控件并替换为其标签(如果要使用标签和按钮)并在标签中设置文件名。这样看来文件就在那里。 FileUpload控件的文件名是只读的,因此您无法分配它。