locked
PostBackTrigger And FileUpload and Textbox RRS feed

  • Question

  • User989035446 posted

    Hi All,

    I have a a master page with upload panel and hence all the control on the pages in under the control of the update panel.

    In order to upload file i need to have post back trigger as per below.

    <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                        <Triggers>
                            <asp:PostBackTrigger ControlID="btnSave" /> 
                        </Triggers>
                        <ContentTemplate>
                            <asp:Button ID="btnSave" runat="server" Text="Save" cssclass="button"  onclick="bnCSave_Click" />
                        </ContentTemplate>
                    </asp:UpdatePanel>

    Meanwhile i have other control(textbox) also that its value need to be readed when the file is upload.

    My problems is the control(textbox)value cannot not be reaeded when the Save button is clicked.

    The Save button should read the uploaded file and also the textbox value.

    I am not able to put all the contol under the PostBackTrigger because of the design.

    I have try to put UpdatePanel to each control but it prompts me below error:

    An extender can't be in a different UpdatePanel than the control it extends.

    Does anyone has idea on this?

    Help Please

    Friday, February 28, 2014 1:44 AM

Answers

  • User-417640953 posted

    An extender can't be in a different UpdatePanel than the control it extends.

    Hi johnsonlim,

    Thank you post the issue to our forum.

    That error message means you placed the Extender controls and Extended controls in different updatepanels.

    For avoiding this error, we must put the both Extender and Extended controls in same updatepanel.

    As you want to upload file with the updatepanel, we should do a full post back by setting PostBackTrigger of updatepanel.

    Since FileUpload control does not work with partial postback which is done in UpdatePanel. FileUpload control requires a full postback.

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

    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    
        <ContentTemplate>
    
            <asp:FileUpload ID="FileUpload1" runat="server" />
    
            <asp:Button ID="btnAsyncUpload" runat="server" 
    
               Text="Async_Upload" OnClick = "Async_Upload_File" />
    
            <asp:Button ID="btnUpload" runat="server" Text="Upload"
    
               OnClick = "Upload_File" />                
    
        </ContentTemplate> 
    
        <Triggers>
    
            <asp:AsyncPostBackTrigger ControlID = "btnAsyncUpload" 
    
              EventName = "Click" />
    
            <asp:PostBackTrigger ControlID = "btnUpload" />
    
        </Triggers>
    
    </asp:UpdatePanel>
    

    If I misunderstand your issue, please feel free to back  and share more information with us. Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, March 3, 2014 9:48 PM