New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the Community Exchange, where community members ask and answer questions about DNN. To get started, just start typing your question below and either select one of the suggested questions or ask a new question of your own.

asp:fileUpload suddenly not working

Return to previous page

  • 4/3/2014
  • 8185 Views

Question:

David Crawley long time ago

The issue that I am having is that my asp:FileUpload function is constantly returning that there is no file entered and if I use the FileUpload.HasFile function it always returns false.  What has me so confused is that about a month ago it was working fine and I havent touched any code that would impact it at all since then, I even rolled back the code (of the entire project) with source control to last version where I knew the upload control was working and still no go.

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Edit.ascx.cs" Inherits="AGP.Modules.AssetManager.Edit" %> <%@ Register TagPrefix="dnn" TagName="label" Src="~/controls/LabelControl.ascx" %> <div id="dnnEditBasicSettings"> <div><a href=""><%=LocalizeString("ExpandAll")%></a></div> <h2 id="dnnSitePanel-BasicSettings"> <a href=""> <%=LocalizeString("BasicUserInfo")%></a></h2> <fieldset>

<div> <dnn:label ID="lblPicFile" runat="server" text="File path for Picture" HelpText="Enter the file path for the picture to upload" /> <asp:FileUpload ID="fuPic" runat="server" Visible="false" Enabled="true" />         <asp:LinkButton ID="btnSavePic" runat="server" Text="Upload" OnClick="btnSave_Click" CssClass="dnnPrimaryAction" Visible="false" /> </div>

(several more <div> containers)

</fieldset> </div>

That is the control code then the code behind for the submit button is

protected void btnSave_Click(object sender, EventArgs e) { if (fuPic.HasFile) { Picture pic = new Picture(); pic.Pic = fuPic.FileBytes; pic.ID = AssetId; AssetController.SetPic(pic); } }

I am not sure what else to include but will be happy to give any details that will help.  

Oh and I am running on a local IIS install with Win 8.1 and DNN Community 07.01.02 and SQL express 2012 with all current updates.

Thanks for any help you might have.

Top Answer:

William Severance long time ago

You didn't happen to turn on "Support's Partial Rendering" in the module's registration or place your code within an ASP.Net UpdatePanel did you? The asp:FileUpload control (or any input element of type="file" requires a full postback to occur.

David Crawley
David Crawley long time ago
OK, I could have sworn I checked that, I DID swear I checked that, but it worked! Ugh.... I pulled out a lot of hair on this and all it was was a dang check box. Thanks for the help and replies William and Sebastian.
Sebastian Leupold long time ago

main question: was has been changed, since the feature broke? a new browser version installed? did you try clearing local browser cache?

David Crawley
David Crawley long time ago
That is what is throwing me for such a loop, I can't think of anything that has changed. I know something must have but I can not figure out what, I have tried it on multiple different machines with no change but I didn't try it on those machines before when it was working. Basically I had it working on my local machine and everything looked good so I ran a release build then installed it on my test server and opened it up so the network could access it for user testing and that is when I noticed the file upload didn't work so I switched back to my local install on my laptop and it didn't work either. I am fairly sure it is not a code problem because I rolled the entire project back with source control back to a point when I know the upload was working and still no go. I will try clearing the browser cache to see if that helps.
David Crawley
David Crawley long time ago
William Severance got it. Somehow, or sometime, I turned on supports partial rendering and that jacked it up, Thanks for the reply Sebastian, I was ready to scream about this.
Sign In to Participate
Or register to become a member