2011-05-10

ASP.NET MVC: Where is the ClientID?

,
For those who are used to program in ASP.NET know this scenario. You have a textbox and you want to do some custom validation in Javascript. You have to be able to access the textbox from the Javascript. The first thing you need to know is the Id for that textbox. You can’t hard code it, because you are not sure how ASP.NET will generate the Id. If the control exists in an INamingContainer, the INamingContainer will add some prefix to the Id of the control. That is where the ClientID property comes to the rescue. This property contains the Id that will be used in HTML. Take a look at this example....
Read more →

2011-05-03

ASP.NET MVC 3 and Unity using an IDependencyResolver

,
In this post i used a custom ControllerFactory for dependency injection. I created a custom ControllerFactory where i overrided the GetControllerInstance method. In this method i used the UnityContainer for creating instances of the requested controller. In ASP.NET MVC 3 their is some build in abstraction for doing dependency injection ( IDependencyResolver ). I will change the example used in this post to use the IDependencyResolver. the IDependencyResolver The IDependencyResolver is a fairly easy interface. It contains only 2 methods: object GetService...
Read more →