web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

FindControl method not working for FileUpload control on EP

(1) ShareShare
ReportReport
Posted on by

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" /> &nbsp;&nbsp;<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)
  • Verified answer
    Community Member Profile Picture
    on at

    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

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans