Post Back does not work after writing files to response in ASP.NET

前端 未结 6 911
刺人心
刺人心 2020-12-15 15:00

What I have?

I have an ASP.NET page which allows the user to download file a on a button click. User can select the file he wants from

6条回答
  •  情歌与酒
    2020-12-15 16:00

    I had this same issue with sharepoint. I have a button on the page that sends a file and after clicking the button, the rest of the form was unresponsive. Turns out it is a sharepoint thing that sets the variable _spFormOnSubmitCalled to true to prevent any further submits. When we send a file this doesn't refresh the page so we need to manually set this variable back to false.

    On your button in the webpart set the OnClientClick to a function in your javascript for the page.

     
    

    Then in the javascript I have this function.

    function setFormSubmitToFalse() {
        setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);
        return true;
    }
    

    The 3 second pause I found was necessary because otherwise I was setting the variable before sharepoint set it. This way I let sharepoint set it normally then I set it back to false right after.

提交回复
热议问题