Monthly Archives: April 2011

Brilliantly Simple Code Sharing

Today I was looking for a fast way to find the index of a nth occurrence of a string in a string, so I found this very simple and intuitive site on which you can find and share .net extension methods, the website is http://www.extensionmethod.net Dah! Smile

I couldn’t find what I looked for, so I shared my solution here; the website made it crazy easy to share this! Something I definitely would add to my log on how to create wonderful websites, simple and effective.

Code Sample Should Be Clean

big_Telerik01The other day I needed an ASP.NET MVC grid control, and I have always heard about Telerik’s ASP.NET MVC Extensions and the great tools they provide, so I decided to give them a try.

So I followed the installation guide step by step, and prepared my code to use the extensions; I added a reference to the DLL, added the scripts, etc… and I thought I was ready to test-drive it.
I opened Telerik’s sample website which showed the control and below it the code sample that made it work, innocently enough I did what any other developer would do to try out the sample code: copy and paste it in your page and then build. To my surprise there was an error in the View; it didn’t recognize an Extension method called “Configurator”!

It was so strange, why wouldn’t it work? I made sure that I added the correct reference dll, that I added the namespaces in the web.config as advised by the guide, and that I used the “using” at the top of my page, but yet it didn’t work.
Ok now that is really strange, I downloaded Reflector ILSpy and disassembled Teleriks dll to make sure that this method exists, and it wasn’t there! where does this Configurator method come from?!

I opened the sample project to make sure of their code, and guess what…the Configurator method was a method that only exists in their sample project; it wasn’t part of the DLL! I wasted considerable time trying to figure this out, and my conclusion was: never use auxiliary code when you are presenting a sample for another code unless you make it clear.