I am trying to upload files from the client to server through asp.net. The problem is that the fileupload control doesn't work inside an TabPanel. Basically the file name and postedfiles properties of fileupload are null after submit. And I can't kick TabPanel out.
I am looking for other solutions. One is that I require the user to input the path of the the files into an input field and submit a button.
The question is how to upload a file based on the path of the file?
Your help will be highly appreciated.
The code is like this. The control id in question is "fuAttachments"
<asp:updatepanel id="upnlForTab" runat="server">
<ContentTemplate>
<asp:TabContainer ID="tcFS" runat="server" ActiveTabIndex="0">
<asp:TabPanel ID="TabPanelAnnualFS" runat="server" HeaderText="AnnualFS">
<ContentTemplate>
<asp:FormView ID="fvAnnualFS" OnDataBound="fvAnnualFS_DataBound" runat="server">
<InsertItemTemplate>
</InsertItemTemplate>
<EditItemTemplate>
<table>
<tr>
<td colspan="2">
Edit a Financial Statement
<asp:HiddenField ID="hfIDStatement" runat="server" />
</td>
</tr>
<tr>
<td>
Attachments:
</td>
<td>
<asp:GridView ID="gvAttachments" AutoGenerateColumns="false" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat="server" Text='<%#Eval("AttachmentName")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:FileUpload ID="fuAttachments" runat="server" />
<asp:Button ID="btnAddAttachment" runat="server" OnClick="btnAddAttachment_Click" Text="Add" />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnSubmitEditAnnualFS" ValidationGroup="SaveFS" OnClick="btnSubmitEditNewAnnualFS_Click"
runat="server" Text="Submit" />
</td>
<td>
</td>
</tr>
</table>
</EditItemTemplate>
</asp:FormView>
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
</ContentTemplate>
in the backend, the code is like this. The problem is that all the properties for fuAttachments are not posted, which is a known issue for file upload control within updatepanel and tabpanel.
/// <summary>
/// Add document to the document list.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnAddAttachment_Click(object sender, EventArgs e)
{
HiddenField hfIDStatement = fvAnnualFS.FindControl("hfIDStatement") as HiddenField;
FileUpload fuAttachments = fvAnnualFS.FindControl("fuAttachments") as FileUpload;
}