I have a AjaxFileUpload control in a usercontrol which is loaded dynamicaly on Postback, the problem here is, once the file is uploaded IsPostBack
is false due to which the usercontrol is not loaded, causing the OnUploadCompleteAll
event to not be triggered.
I found out that AjaxFileUpload control has its own postback property AjaxFileUpload.IsInFileUploadPostBack
, how do i access this property from my main WebForm1.aspx page?
When an event is triggered from AjaxFileUpload i would like to check IsInFileUploadPostBack
on page load of WebForm1.aspx and then load the usercontrol.
here is the code.
WebForm1.aspx
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Button ID="Button1" runat="server" Text="Load Control" OnClick="Button1_Click" />
<asp:PlaceHolder ID="Placeholder1" runat="server" />
</form>
Codebehind
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
loadcontrol();
}
protected void Button1_Click(object sender, EventArgs e)
{
}
private void loadcontrol()
{
this.Placeholder1.Controls.Clear();
var _controls = LoadControl("~/WebUserControl1.ascx");
this.Placeholder1.Controls.Add(_controls);
}
WebUserControl1.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs" Inherits="AjaxFileUpload_Test.WebUserControl1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<div id="div1">
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" UseAbsoluteHandlerPath="false" OnUploadCompleteAll="AjaxFileUpload1_UploadCompleteAll" OnUploadStart="AjaxFileUpload1_UploadStart" runat="server" />
</div>