Search code examples
c#asp.netfile-uploadfilenames

ASP.net File Upload - FileBytes, FileName


Hi I am using a File Upload Control within ASP. i am unable to get File Name or File Bytes within my c# code

aspx

 Upload Image: <asp:FileUpload runat="server" ID="fu" /> 
<asp:LinkButton ID="lnkContinue" runat="server" class="ButtonGeneric" onCommand="lnkContinue_Click">CLICK</asp:LinkButton>

cs Code

protected void btnNext_Click(object sender, EventArgs e)
        {
 string fileName = fu.FileName;
 int DocumentID = DocumentsComponent.SaveFileByJobID(JobId, UserID, fileName,fu.FileBytes, txtDescription.Text, 1);
}

i might have to store the bytes into a byte variable , but i still don't get anything populated within filename string.

update panel in the master page:

<div id="content">
                    <asp:UpdatePanel runat="server" ChildrenAsTriggers="true" ID="up" UpdateMode="Conditional">
                        <ContentTemplate><asp:ContentPlaceHolder id="cph" runat="server" /></ContentTemplate>
                    </asp:UpdatePanel>
                </div>

Solution

  • for benefit of other users following this post, as #banana helped me to steer towards the right direction, the problem is with the update panel being used in the master page that i am referencing, removing the update panel will do the job. if i want to keep the update panel i need to use triggers which is beyond the scope of this post.