This code does not compile because the viewData variable on line 15 does not exist.
But I'm presuming the "viewData" variable on line 15 was intended to be "vd".
Thanks for spotting, updated now.
Hi, I've been trying to use your code, but I am having some problems when HtmlHelper is instanciated.I've detailed the problem here: http://stackoverflow.com/questions/3445770/missingmethodexception-thrown-when-trying-to-mock-htmlhelper-with-moqapparently the ViewContext constructor's signature has changed, but even when supplying an updated Mock, I'm seeing a MissingMethodException being thrown.
Eric,check out a version for MVC 2 and 3 in this new post.