Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

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 DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesfileupload issuefileupload issue
Previous
 
Next
New Post
3/12/2012 7:01 PM
 

Hi,

i'm using DNN 6.1.3, .net framework 4 and i have a problem with fileupload.
When i try to use fileupload control this don't get the filename selected.
here the simple HTML code:

<table>
    <tr>
        <td>
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
            <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        </td>
    </tr>
</table>


and here the codebehind:

protected void Button1_Click(object sender, EventArgs e) {
HttpPostedFile flname = FileUpload1.PostedFile;
Label1.Text = flname.FileName;
Label1.Text = FileUpload1.FileName;
}

the FileName property is always empty and if i try to use the property FileUpload1.HasFile it is always set to false.

Thanks for the help
Emiliano Provenzano

 

 
New Post
3/12/2012 7:48 PM
 

That's a typical issue if you forget or don't realize that the asp:fileupload control requires a full postback for the upload to occur. If  your "Button1" is wrapped in an AJAX update panel - either of your own creation or one that is applied by the DNN framework when a module control's "Supports Partial Rendering" option is enabled, only an AJAX callback will occur. The solution is to either not use an Update panel or to register Button1 as a postback control:

DotNetNuke.Framework.AJAX.RegisterPostBackControl(Button1);

Rather than creating your own file upload code, it would also be well to look into using either the DotNetNuke Url control or (my preference) the DotNetNuke.Web.UI.WebControls.DnnFilePicker control which will not only perform the upload but will properly add the file metadata to the DNN database tables.


Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
3/13/2012 6:11 PM
 

William thank you very much for the solution!
i have no ajax function on my page and uncheck the support partial rendering on the page is enough.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesfileupload issuefileupload issue


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out