locked
Updatepanel in masterpage, trigger the FileUpload in a child webform-Help RRS feed

  • Question

  • User-721356704 posted

    I try to pass the postbacktrigger in the child webform using this code:

    protected void Page_Load(object sender, EventArgs e)
    {
    //For file upload to be triggers
    UpdatePanel updatepanel = Page.Master.FindControl("UpdatePanel1") as UpdatePanel;
    UpdatePanelControlTrigger trigger = new PostBackTrigger();
    trigger.ControlID = FileUpload1.UniqueID;
    updatepanel.Triggers.Add(trigger);
    }

    But I got this error:
    "Control with ID 'FileUpload1' being registered through RegisterAsyncPostBackControl
    or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler,
    or IPostBackEventHandler."

    Masterpage design source:
    <form id="form1" runat="server">
    <div>
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

    <asp:UpdateProgress runat="server">
    <ProgressTemplate>
    <div class="upmodal">
    <div class="upcenter">
    Please wait... processing...
    <img alt="" src="Loading.GIF" />
    </div>
    </div>
    </ProgressTemplate>
    </asp:UpdateProgress>

    <asp:UpdatePanel ID ="UpdatePanel1" runat="server" UpdateMode ="Conditional" >
    <Triggers >
    <asp:AsyncPostBackTrigger ControlID ="Button1" />
    </Triggers>
    <ContentTemplate>

    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    </ContentTemplate>
    </asp:UpdatePanel>

    </div>
    </form>


    Child Webform Design source:
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:FileUpload ID="FileUpload1" runat ="server" AllowMultiple ="true" />
    <asp:Button ID ="btnUpload" Text ="Upload it" runat ="server" OnClick ="Click_Upload" />
    <asp:Label ID="Label1" runat ="server" ></asp:Label>
    </asp:Content>

    Please Help Thanks
    Monday, February 1, 2016 10:17 AM

All replies

  • User79986525 posted

    Hi 

    Remove this line

    <Triggers >
    <asp:AsyncPostBackTrigger ControlID ="Button1" />
    </Triggers> 

    Monday, February 1, 2016 12:02 PM
  • User-721356704 posted
    Thanks for response,

    Suddenly displaying same error.
    Monday, February 1, 2016 12:30 PM
  • User61956409 posted

    Hi Jen C.

    Normally, we don’t set FileUpload control as Trigger, you could try to set upload button as PostBackTrigger.

    http://www.aspsnippets.com/Articles/Using-FileUpload-Control-inside-ASP.Net-AJAX-UpdatePanel-Control.aspx

    Best Regards,

    Fei Han

    Tuesday, February 2, 2016 7:11 AM
  • User-721356704 posted
    Thanks

    The upload button work perfectly the, the problem of my code is the FileUpload hasfile always have a false value.
    What i trying to do is to monitor the activity of child webform,if the child form is busy the updateprogress display instantly.

    If examine my html in masterpage I put the ContentPlaceholder inside the updatepanel control,

    <asp:UpdatePanel ID ="UpdatePanel1" runat="server" UpdateMode ="Conditional" >
    <Triggers >
    <asp:AsyncPostBackTrigger ControlID ="Button1" />
    </Triggers>
    <ContentTemplate>

    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
    </asp:ContentPlaceHolder>
    </ContentTemplate>
    </asp:UpdatePanel>

    </div>
    Tuesday, February 2, 2016 8:31 AM