开发者

updatepanel.update() doesn't appear to fire from code-behind

I have an updatepanel that I change the content of and then call updatepanel.update() to asynchronously update that section of the page, but it does not appear to fire the update() from the code-behind (ie. the Async Post Back doesn't happen and doesn't display the updated content.

The following scriptmanager is in a MasterPage:

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" ></asp:ToolkitScriptManager>

The page in question has the following update pane开发者_开发技巧l:

<asp:UpdatePanel ID="upImageConfirm" runat="server" UpdateMode="always">
    <ContentTemplate>
        <div id="imageContainer">
            <asp:label ID="lblCheckPackshot" runat="server" Text="None" />
            <asp:button ID="btnLoadPackshot" runat="server" OnClick="uploadPackShot" Text="Upload &raquo;" />
        </div>
    </ContentTemplate>
</asp:UpdatePanel>

The following codebehind is kicked off and run when a file upload is complete (checking in debugging this code does run and does change the values, but the update isn't fired:

protected void uploadComplete(object sender, jaxControlToolkit.AsyncFileUploadEventArgs e)
{
try
{
            //upload file to web file system
            if (afuStockImport.HasFile)
            {
                string strPath = Server.MapPath("~/graphics/holding/") + Path.GetFileName(afuStockImport.PostedFile.FileName);
                Session["uploadedFileName"] = afuStockImport.PostedFile.FileName;
                afuStockImport.SaveAs(strPath);

                //Show on page for confirmation
                lblCheckPackshot.Text = "<img src=\"/graphics/holding/" + Path.GetFileName(afuStockImport.PostedFile.FileName) + "\" />";
                upImageConfirm.Update();
            }
        }
}

Thanks!


This is a behavior with the AsyncFileUpload from ASP.NET AJAX Toolkit. The problem is that the AsyncFileUpload use a iframe to handle the asynchronous upload, so the "page" that raise the uploadComplete event and the the client page is not linked the same way as usual.

On workaround for that is to use the OnClientUploadComplete event to trigger an asyncpostback using javascript and then update your updatepanel. There is many others way of doing this, some are not using an update panel.


Technically you can't do Async file uploads. The implementations that exist are all workarounds...hidden IFrames, TextAreas...etc

Why don't file uploads work during async postbacks?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜