I have a report that feeds the user a TDF text file. Two filters are selected and two fields are filled out before the user can submit, with a friendly error message appearing if the "download" button is clicked without them, requesting the user complete these fields before continuing. My testing departments wants this error to go away upon successful download of the file. The response object stops the page from posting back so the error message can disappear.
To attempt to work around this I've added an extra, invisible button wired up to the code creating the TDF, and attached a Javascript click event to the visible button.
<asp:Button ID="btnSubmit" runat="server" Text="" Style="visibility:hidden;" /><asp:Button ID="btnDownload" runat="server" Text="Download TDF" OnClientClick="document.getElementById('ctl00_MainContent_btnSubmit').click();" />
My problem is, for reasons unbeknownst to me, the code behind isn't firing when this hidden button is clicked. If I throw an alert on the hidden button, it fires just fine, telling me the button is being clicked. The event is registered in the button's Events list, and I do have the event listener wired up:
Protected Sub btnSubmit_Click(sender As Object, e As EventArgs) Handles btnSubmit.Click
I have commented out everything to do with creating and downloading the TDF file, instead setting a dummy error message to see if the page reacts, it does not.
Why is my code behind not running?