
I have FileUpload control in EP user control as shown below.
<dynamics:AxSection ID="FileUploadSection" runat="server" Caption="<%$ AxLabel:@SYS93173 %>">
<dynamics:AxGroup ID="FileUploadGroup" runat="server">
<Fields>
<asp:TemplateField ><InsertItemTemplate>
<asp:FileUpload ID="uploadDoc" runat="server" /> <asp:Button runat="server" ID="btnFileUpload" Text="Upload" OnClick="btnFileUpload_Click"/></InsertItemTemplate>
</asp:TemplateField>
</Fields>
</dynamics:AxGroup>
</dynamics:AxSection>
when in codebehind file i try to find the control , it returns null.
FileUpload fileuploadctrl = (FileUpload)this.FileUploadSection.FindControl("uploadDoc");
here fileuploadctrl returns as null. what's the reason ? why control is not being captured using FindControl method here?
Please guide. Thanks.
*This post is locked for comments
I have the same question (0)Got it. You need to Find control using FindControl Method if you have single file control on page.
You can write below code
if (Request.Files == null || Request.Files.Count == 0 || Request.Files[0].FileName == string.Empty)
{
// File is not selected from file upload control
}
else
{
// file is selected from file upload control
}