AjaxFileUpload postback false

匿名 (未验证) 提交于 2019-12-03 08:48:34

问题:

i am using AjaxFileUpload in ASP.NET 4.0 website. The problem is that when i upload a file its UploadComplete fires which causes a postback to page. on every postback caused by AjaxFileUpload the Ispostback property is False which should be True. What is the reason. I checked it in the updatePanel and without it. It has no affect at it. Here is the

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

回答1:

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



回答2:

Its a direct solution code of this problem

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         } } 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!