Skip to main content


Showing posts from 2011

How to use jQuery to disable a hyperlink image on click in an ASP.NET MVC 2 View

In one of my recent projects, my view displayed a table of hardware alerts for set of monitored devices. On any of the alerts, the user had three potential actions: close, initiate a chat session, or email tech support.

The latter two actions are pretty simple, as they are just hyperlinks that open in a new window. Close Alert, on the other hand, is an MVC ActionLink that goes back to Alert/Close/{Id}.

The problem with this function is that it's not re-entrant. User testing indicated that some people are so accustomed to double-clicking that they would inadvertently try to close the same alert twice. QA asked me to come up with a solution.

Yes, I know I should also guard against this in the controller. However, trying to close an alert doesn't cause any data corruption (it just doesn't work and the user gets an ugly error message). The issue is entirely one of user-experience. Because of that, and the fact that I needed something quick, I turned to jQuery. Our site makes…