Fileupload AJAX And UserControl (ASCX)

Jul 21, 2008 at 9:07 AM
How to use Fileupload Ajax and UserControl (Ascx). I can not use. Pls help me
Sep 19, 2008 at 12:28 PM

I'm also unable to use this control in my own Usercontrol. Therefore it's useless to me and that's a pity.

Is there a way to use it in my own Usercontrol? Thanks for your answer.

Dec 11, 2008 at 9:49 PM
I was able to do this just fine in C# 3.5.  (My usercontrol is named FlipperModal.ascx)

ASCX:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="FlipperModal.ascx.cs" Inherits="UserControls_FlipperModal" %>
<%@ Register Assembly="FUA" Namespace="Subgurim.Controles" TagPrefix="cc1" %> 

<cc1:FileUploaderAJAX ID="FileUploaderAJAX1" runat="server" MaxFiles="1" CssClass="Text"
    showDeletedFilesOnPostBack="false" File_RenameIfAlreadyExists="true" />
<div id="info" style="overflow:auto; font-family: Arial, Verdana, Tahoma;"></div> 

ASCX.CS:

using Subgurim.Controles;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (FileUploaderAJAX1.IsPosting)
            this.managePost();
    }

    private void managePost()
    {
        HttpPostedFileAJAX pf = FileUploaderAJAX1.PostedFile;

        if (pf.Type == HttpPostedFileAJAX.fileType.image)
            FileUploaderAJAX1.SaveAs(Page.ResolveUrl("~/Images/Thumbnails/"), pf.FileName);

        FileUploaderAJAX1.PostedFile.responseMessage_Uploaded_NotSaved = "<span style=\"font-family: arial; font-size: 12px;\">Sorry, there was a problem uploading this file.</span>";
    }