Detect-Browser-File-Download-Dialog-Sample is a project mainly written in JavaScript, it's free.
Sample ASP .NET MVC app for demonstrating how to "detect" when the browser file download dialog appears. A summary of this approach can be found on my blog:
404: Not Found