Here are 2 chunks of my code.
The calling page HTML:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="FileDownload.aspx.vb" Inherits="WebUtilities.FileDownload"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>frmDownload</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="
name="vs_targetSchema">
<script language=javascript>
function disablemybutton()
{
document.getElementById("btnDownloadCSV"

.disabled=true
}
</script>
</HEAD>
<body bgColor="#ffffcc" MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:button id="btnDownloadCSV" style="Z-INDEX: 101; LEFT: 24px; POSITION: absolute; TOP: 56px" tabIndex="1" runat="server" Height="24px" Width="104px" Text="Download CSV"></asp:button>
....
....
</form>
</body>
</HTML>
The code behind (vb part):
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnDownloadCSV.Attributes("onclick"

= "javascript:return disablemybutton();"
....
....
End Sub
Private Sub btnDownloadCSV_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownloadCSV.Click
' Call the actual download function
DownLoadFile(eReportFormat.CSV)
End Sub