Archive for the 'aspmvc' Category

Stubbing out ServiceLocator for unit testing

Wednesday, June 30th, 2010

There are certainly many ways to stub out dependency, using constructor injection, etc etc. Here is one way to quickly stub out ServiceLocator rather than implementing ServiceLocatorStub. Lets say you have code that uses a helper and the dependency is not quite the responsibility of that object but its the sub object that uses it. [...]

  • Share/Bookmark

Json A circular reference was detected while serializing an object of type … in my asp mvc app

Wednesday, June 9th, 2010

I found this weird error when I was testing a no trivial test case in my app and was not able to find out what was wrong with it. It appears like a Json error in my asp mvc app, although the stack really doesn’t help ?View Code CSHARP1 2 3 4 5 6 7 [...]

  • Share/Bookmark

ASP .NET MVC2 Changes: GetControllerInstance & DataAnnotationsModelBinder

Tuesday, March 30th, 2010

So was in the process of updating my mvc app, there is a tool that does it for you and also a manual way . But once you have updated there are also 2 more changes that you may need if you are using IoC or DataAnnotations. First you will need to change the method [...]

  • Share/Bookmark

SparkViewEngine: Highlight Table Alt Row

Monday, March 29th, 2010

Here is how one highlights an alt row with spark, quite clean I tell you. Assuming you have a css that like below. ?View Code CSS1 2 3 4 5 6 tr.alt { text-align: left; padding: 2px; border: 1px solid #000; background: #ADDFFF; } And in your template you will call it like this. ?View [...]

  • Share/Bookmark

Url Helper Extension Method for ASP MVC in form tags when using IIS 6

Monday, December 21st, 2009

So I was going through some code of codebettercanvas and found it interesting of Karl Seguin using Html Helper extension for his form tags, which has its elegance. e.g ?View Code HTML1 <form id="login" action="!{Html.LinkTo<HomeController>(c => c.Login()) }" method="post"> Basically it calls an extension method called LinkTo with a generic controller and a lamda for [...]

  • Share/Bookmark