Calling a confirm dialog box on code behind and get the chosen option
<p>I'm developing an asp.net application and I need to call a confirm dialog box on the code behind. And after that, I need to get the user's click (if he clicked at OK or Cancel).</p>

<p>If he clicked the OK button of the dialog, I must continue to running the code where I stopped before call the dialog.</p>

<p>To solve this problem I thought in put at the aspx an input of type button, and set it's style  to visibility:hide. So, when the users click on the OK button the programm will call this hidden button which calls a method that will continue the job stopped.</p>

<p>I'll post my code, I expect it might help.</p>

<p>The code below is on my code behind, and it calls the confirm dialog.</p>

<pre><code>System.Web.UI.
    ScriptManager.RegisterClientScriptBlock(this, GetType(), "__Mensagem", "if (confirm('" + CustomMessage + "')){document.getElementById(\'&lt;%=btnSave.ClientID%&gt;\').click();}", true); 
</code></pre>

<p>The code below is on my aspx, it's the "hidden" button.</p>

<pre><code>&lt;input style="visibility:hidden;" id="btnSave" runat="server" onclick="btnSave_Click"/&gt;
</code></pre>

<p>I don't know why isn't working. The error that I receive after click on the button OK of the confirm dialog box is the following: Erro em tempo de execução do Microsoft JScript: 'document.getElementByID(...)' é nulo ou não é um objeto</p>

<p>I'm from Brazil so the error is in portuguese, a translation to english it's something like this:</p>

<p><b>"A runtime error occurred on Microsoft JScript 'document.getElementByID(...)' is null or is not an object"</b></p>

<p>I give a look at the html code of the page and I notice that the button isn't there.</p>

<p>Maybe it's because I'm using an UpdatePanel, but when I removed it (just for tests, I must use the Update Panel), the same error is showed, and in this time the button were on the page's html code.</p>
