Welcome Guest Search | Active Topics | Sign In | Register

AjaxUploader don't work in UserControl Options
Guilhem
Posted: Monday, August 24, 2009 11:23:32 AM
Rank: Newbie
Groups: Member

Joined: 8/24/2009
Posts: 2
Hello,

i've a masterPage that load usercontrol dynamiquely.
In a userControl i have an AjaxUploader, the files are uploaded but the event OnFileUploaded don't fire and my PostedFiles is empty.

My userControl is like this (ascx):

Code: HTML/ASPX
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Appairage.ascx.cs" Inherits="Synox.M2M.Web.Extranet.Controles.Transmetteur.Appairage" %>
<eo:CallbackPanel runat="server" id="CallbackPanel1" Triggers="{ControlID:AJAXUploader1;Parameter:}">
                    <eo:AJAXUploader ID="AJAXUploader1" EnableViewState="true" runat="server" Width="250px"  AutoPostBack="true" AutoUpload="true" MaxFileCount="1" TempFileLocation="~/Upload/" FinalFileLocation="~/Upload/"  FinalFileList="AJAXPostedFileList1" OnFileUploaded="AJAXUploader_FileUploaded" MaxDataSize="10000" UseLinkButton="False" Rows="1">
<TextBoxStyle CssText="width:100px" />
                        </eo:AJAXUploader>
                        </eo:CallbackPanel>
                        <eo:AJAXPostedFileList  runat="server" ID="AJAXPostedFileList1" />


The C# code :
Code: C#
protected void Page_Load(object sender, EventArgs e)
        {
            Bind();
            
            // Initialisation des controles de la MasterPage
            //On regarde si un post est en cours
                //((Formulaires.MasterPage.M2M)Page.Master).RefreshUI("Appairage (Affectation SIM et client à un transmetteur)", 930, "../../Images/Icones/Boitiers.png");

                
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            
        }
        #endregion

        #region Evenements
        protected void AJAXUploader_FileUploaded(object sender, System.EventArgs e)

        {
            AJAXUploader1.Visible = false;

            foreach (EO.Web.AJAXPostedFile file in AJAXUploader1.PostedFiles)
            {
                //Get the temp file name
                string tempFileName = file.TempFileName;
                
                //Create the final file name based on the original file name
                string finalFileName = System.IO.Path.Combine(Server.MapPath("~/Upload/"), file.ClientFileName);

                //Move the file to the desired location
                System.IO.File.Move(tempFileName, finalFileName);
            }

        }
#endregion


If you've got a solution, i buy the licence !
Sincerely
eo_support
Posted: Monday, August 24, 2009 11:33:20 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The code you posted is fine. The problem is most likely related to the dynamic loading code. The general rule for dynamic loading is that you must reload the exact same control again at the same location when the page posts back. And you would usually do it inside your Page_Init (instead of Page_Load) for such reloading.

Our demo project uses it exactly this way. In our demo project, every demo (including all the AJAXUploader demos) you see on the right side panel is a user control that is dynamically loaded. When user clicks a TreeNode from the tree on the left side, the code loads the corresponding demo user control. It also "remembers" the last loaded demo with a hidden field (do not use ViewState because ViewState has not been loaded when Page_Init called). If the demo causes a post back, the page will then rely on the value of this hidden field to reload the last demo. You can take a look of the code inside Page_Init handler in Default.aspx.cs/.vb to see how this works.

Please feel free to let us know if you still can not get it to work. In that case we may ask you to create a test project that demonstrates the problem and send the project to us. As soon as we have that we should be able to tell you exactly what's wrong.

Thanks!
Guilhem
Posted: Tuesday, August 25, 2009 8:54:35 AM
Rank: Newbie
Groups: Member

Joined: 8/24/2009
Posts: 2
Hello,

thanks you for the response, i ve forgotten to rebuild the hierarchy controls in the page_init.

Now the control work fine and i bought a full license.

Thanks you,

Sincerely,

Guilhem BERTHALON

Groupe SYNOX
eo_support
Posted: Tuesday, August 25, 2009 8:58:36 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Glad to hear that. Thank you very much for your business! Please feel free to let us know if you have any more questions.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.