5

AjaxFileUploadASP.NET 4.0网站上使用。问题是,当我上传文件时,它UploadComplete会触发回发到页面。对每一个postback造成AjaxFileUploadIspostback财产是False哪个应该的True。是什么原因。我检查了它updatePanel和没有它。它对它没有影响。这里是

  <ajax:AjaxFileUpload ID="AjaxFileUpload1" ContextKeys="fred" 
     AllowedFileTypes="jpg,jpeg,png,gif" MaximumNumberOfFiles="3" runat="server" 
        OnUploadComplete="AjaxFileUpload1_UploadComplete" />
4

2 回答 2

11

To detect postback from the AjaxFileUpload use this control's property: AjaxFileUpload.IsInFileUploadPostBack. The IsPostBack property doesn't works because this control submits not to the same page where is was rendered but to hidden frame instead so it's the first time for frame it loading on server. See more in AjaxControlToolkit sources: AjaxControlToolkit AjaxFileUpload

于 2013-02-02T20:10:44.760 回答
0

它是这个问题的直接解决方案代码

protected void Page_Load(object sender, EventArgs e) 
 {
        // check if postback came through AjaxFileUpload control
        if (AjaxFileUpload1.IsInFileUploadPostBack)
        {
            // do for ajax file upload partial postback request
        }
        else
        { 
            // do for normal page request
        }
}
于 2016-03-11T07:48:12.847 回答