Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Trouble with File upload function in asp.net


  • Please log in to reply
1 reply to this topic

#1 hispaladin

hispaladin

  • Members
  • 245 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Middle of a corn field
  • Local time:08:12 PM

Posted 03 April 2014 - 11:16 AM

I am building a website and am using DNN 7, I am trying to get an asp:fileUpload function to work and it is giving me lots of crap.  the most frustrating thing is that it was working about a month ago and I am not really sure when it quit.  I have rolled back the source code back to when we first got it working and it still does not work (this is the same code that worked flawlessly a month ago).  I have done a lot of digging on this and have come up with a lot saying that it will not work right in a update Panel but I am not using an update panel.  Here is the .ascx file minus the extra div containers (they would make it a really long file)

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Edit.ascx.cs" Inherits="AGP.Modules.AssetManager.Edit" %>
<%@ Register TagPrefix="dnn" TagName="label" Src="~/controls/LabelControl.ascx" %>

<div class="dnnForm dnnEditBasicSettings" id="dnnEditBasicSettings">
    <div class="dnnFormExpandContent dnnRight "><a href=""><%=LocalizeString("ExpandAll")%></a></div>

    <h2 id="dnnSitePanel-BasicSettings" class="dnnFormSectionHead dnnClear">
        <a href="" class="dnnSectionExpanded">
            <%=LocalizeString("BasicUserInfo")%></a></h2>
 
    <fieldset>
        (several <div> containers but they are not nested)
    </fieldset>
    <h2 id="H1" class="dnnFormSectionHead dnnClear"><a href="" class="dnnSectionExpanded"><%=LocalizeString("AdditionalInfo")%></a></h2>
    <fieldset>
        <div class="dnnFormItem">
            <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" />&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp
            <asp:LinkButton ID="btnSavePic" runat="server" Text="Upload" OnClick="btnSave_Click" CssClass="dnnPrimaryAction" Visible="false" />
        </div>
        (several more <div> containers but again not nested)
    </fieldset>
</div>
 
<asp:LinkButton ID="btnSubmit" Text="Save Asset" runat="server" OnClick="btnSubmit_Click" CssClass="dnnPrimaryAction" CausesValidation="true" />&nbsp;&nbsp;&nbsp;
<asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" OnClick="btnCancel_Click" CssClass="dnnSecondaryAction" CausesValidation="false" />
 
<script language="javascript" type="text/javascript">
    /*globals jQuery, window, Sys */
    (function ($, Sys) {
        function dnnEditBasicSettings() {
            $('#dnnEditBasicSettings').dnnPanels();
            $('#dnnEditBasicSettings .dnnFormExpandContent a').dnnExpandAll({ expandText: '<%=Localization.GetString("ExpandAll", LocalResourceFile)%>', collapseText: '<%=Localization.GetString("CollapseAll", LocalResourceFile)%>', targetArea: '#dnnEditBasicSettings' });
        }
 
        $(document).ready(function () {
            dnnEditBasicSettings();
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
                dnnEditBasicSettings();
            });
        });
 
    }(jQuery, window.Sys));
</script>

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 have it set to visible = false at first so that the control is only available after the asset object is created.  

I am running windows 8.1 pro and running IIS locally with SQL express also locally installed.  For my testing everything is local.  Not sure what else to add but will happily give any information that could be helpful.

Thanks for any help you might have.


Edited by hispaladin, 03 April 2014 - 11:17 AM.


BC AdBot (Login to Remove)

 


#2 hispaladin

hispaladin
  • Topic Starter

  • Members
  • 245 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Middle of a corn field
  • Local time:08:12 PM

Posted 04 April 2014 - 09:02 AM

OK got the problem fixed.  Turns out that somehow (somehow being me at some point) the page got set to "support partial rendering" which prevents the page from doing a full postback which is required for the asp:fileUpload function to work.  Unchecked that little box in the DNN extensions section for that module and all is well.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users