locked
btnPostbackTrigger RRS feed

  • Question

  • User-153404742 posted

    I have a postbackTrigger defined for a button when trying to download a file from azure blob.  If the file does not exist in the blob, the program catches the exception but it returns an undefined object for json that returns the tree structure for the folder.  so I have the following happening when trying to download:

     document.getElementById('<%= btnPostbackTrigger.ClientID%>').click();

    <asp:Button ID="btnPostbackTrigger" runat="server" OnClick="btnTrigger_Click" Width="0px" Height="0px" style="visibility:hidden" />

    In the end_request, I'm trying to reset the treeview as it needs to grab the latest object after deletion:

     Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function (sender, args) {

                if (sender._postBackSettings.sourceElement != undefined && sender._postBackSettings.sourceElement.id.length > 0) {
                    var srcElement = sender._postBackSettings.sourceElement;

                    if (srcElement.id == '<%= btnTrigger.ClientID %>' && args.get_error() == null) {
    ...

    However, I get the "undefined" when trying to parse the json object as it is an empty string.  How do I go about ignoring the error and still reload the treeview?  

    Tuesday, November 3, 2020 7:13 PM

All replies

  • User1535942433 posted

    Hi inkaln,

    Accroding to your description,you don't post more details of your json codes.

    You could debug and check whether to receive json data correctly and whether whether to convert json data correctly.

    You could post more codes of json data to us.It will help us to solve your problems.

    Best regards,

    Yijing Sun

    Wednesday, November 4, 2020 7:42 AM
  • User-153404742 posted

    JSON object on page load is fine...any click event and asyncpostback goes through fine, which triggers a button click and causes postback but it's inside the update panel so doesn't do a full postback.  However, if there is any error when trying to download a folder or file, which is the only postback event there is on the page, it goes through and I try to pass in the json object but it is not passed because of the error and returns undefined.  If I reload the page in the download function, it'll populate fine...but not reloading it will throw undefined error because of the error in catch exception.  I actually don't want to do a reload....

    Wednesday, November 4, 2020 5:11 PM
  • User1535942433 posted

    Hi inkaln,

    Download file must a full postback and it's fit with updatepanel.So, I think,it couldn't download files without reloading.

    Best regards,

    Yijing Sun 

    Friday, November 6, 2020 9:10 AM