1

I have a html input control within a asp:UpdatePanel and I have its associated upload button specified within a asp:PostBackTrigger tag. Here is the aspx code:

<asp:UpdatePanel ID="upGallery" UpdateMode="Conditional" runat="server">

<ContentTemplate>
    <portal:ModuleTitleControl id="Title1" runat="server" />
    <portal:OuterBodyPanel ID="pnlOuterBody" runat="server">
    <portal:InnerBodyPanel ID="pnlInnerBody" runat="server" CssClass="modulecontent">

<div id="Uploader" runat="server">
    <h2>Upload a docx file to be translated.</h2>
    <input id="input_FileUpload" runat="server" type="file" />
    <asp:Button ID="button_UploadFile" runat="server" OnClick="button_UploadFile_Click" Text="Upload" />
</div>

</portal:InnerBodyPanel>
</portal:OuterBodyPanel>
</ContentTemplate>
<Triggers>
    <asp:PostBackTrigger ControlID="button_UploadFile" />
</Triggers>
</asp:UpdatePanel>

Here is the code behind to retrieve the value of the input control "input_FileUpload":

string filename = input_FileUpload.Value;

filename is always empty when I step through the code.

What am I doing wrong?

Darren
  • 793
  • 5
  • 17
  • 30

1 Answers1

2

The FileUpload control has known problems with the UpdatePanel. Check out this prior discussion: FileUpload control inside an UpdatePanel without refreshing the whole page?

Community
  • 1
  • 1
vpiTriumph
  • 3,116
  • 2
  • 27
  • 39
  • I am not using the asp:FileUpload control. It is only a html input element. – Darren Apr 10 '12 at 03:36
  • 1
    An asp:FileUpload control renders as an box so it's essentially equivalent. – vpiTriumph Apr 10 '12 at 03:57
  • I can't use a html input with a runat="server" attribute? – Darren Apr 10 '12 at 13:15
  • I switched from using a asp:FileUpload because it inexplicably stopped working and because I couldn't style it properly. – Darren Apr 10 '12 at 13:22
  • What I'm getting at is that they're equivalent and, as a result, in an UpdatePanel neither is going to function. Outside of an UpdatePanel either syntax would work just fine. – vpiTriumph Apr 10 '12 at 18:25
  • Unfortunately, I have no choice but to place something within that UpdatePanel because it is in a template page in a CMS. I will see if I can find a workaround and I will also check the couple of solutions I saw mentioned in your answer. However, I would also like to ask if there are any controls or anything else you would recommend. – Darren Apr 10 '12 at 18:44