Update 1/28/2010: This article is Scott Guthrie approved (Corporate Vice President in the Microsoft Developer Division). There are occasions when you are developing a form and you need to have a drop down list that dynamically populates based on the value of another control. The classic example is a contact form that dynamically populates the states and provinces list when a country is selected. For example, when I select "United States" I want the child drop down to have entries like New York, Alabama, Texas and etcetera. When I select "Canada" I would expect to see provinces like Nova Scotia and Ontario. Fortunately, this functionality is very easy to build using ASP.NET MVC and jQuery. Best of all, we can do this without any postbacks using the jQuery Ajax functions. To get started make sure you have a reference to the jQuery library, preferably in the HEAD section of your html. For the purposes of this example I am using jQuery version 1.4. You can either ... [More]
My first encounter with programming was around 1992 when I developed my first website. The website was complete with frames, flashing gifs and marquee tags. It was an absolute nightmare! Anyway, I gradually learned enough about computers and coding that I suckered a small company into giving me an internship. Although, I was hired to fix computers and maintain the test lab, I secretly always wanted to write code. Eventually, I convinced my boss to let me take home the Delphi 4 CD and a few months later I was hired full time as a software engineer.
Between my first hello world program and now, many things have changed. Programming languages have come and gone. We went from waterfall to agile and from extreme programming to test driven design. Nonetheless there are certain ideas and principals around computer programming that never seem to change. That is really the whole idea behind this post.
Never write code with the intention that you will fix it later - Chances are you will never ... [More]
Most experienced developers will tell you that end users tend to "judge an application by its cover". In other words, they don't care how long you spent building an application or what techniques you employed to build it. They are only concerned with how it looks. I can recall a few times in my life where I spent many endless days and nights building an application just to meet a deadline and the first remark from the end-users was "can you change the color of that label" or "can you put our logo on the main page". They don't care that the application meets the specifications or that the project was on time and under budget, that was expected. They are more concerned with the way things look. In my current job, I built an ASP.NET MVC application to track server inventory. Overall the application is a huge improvement over the previous tracking tools. Which by the way, consisted of a few excel spreadsheets stored on a remote file share. Strangely enough, t... [More]
In ASP.NET MVC it is common practice to sprinkle attributes all over your controller methods to enforce security. For example if I have an administrative section of my website that I want to restrict to users in the Admin Role I could write the following snippet of code [Authorize( Roles = "BUILTIN\\Administrators" )]
public ActionResult LoginHistory( string userID )
This style of securing your controller methods is convenient but it can become a nightmare to maintain. Especially if you later determine that the admin functionality in your application now should be available to the members of several Active Directory groups and a couple of random users. Due to this change, your code would end up looking something like this:
[Authorize( Roles = "MYDOMAIN\\Admins,MYDOMAIN\\Developers,MYDOMAIN\\Managers", Users = "MYDOMAIN\\User1,MYDOMAIN\\User2" )]
public ActionResult LoginHistory( st... [More]
BlogEngine 1.6.1 includes support for ReCaptcha. This tutorial applies to BlogEngine 1.5 and 1.6
Since I started using BlogEngine.NET I noticed that I get a ton of comments that are spam. Yesterday, I discovered a blog post on how to use reCaptcha in BlogEngine.Net by Keith Ratliff. The solution was well done, but I was not happy with the end result because it disabled the Ajax functionality.
Fortunately, while reading the comments of that same blog post by Keith, I found a second solution which was written by Alpha Wu. Alpha's solution maintains the Ajax functionality. The only main difference is that Keith's solution uses reCaptcha (slightly more sophisticated) while Alpha's solution custom draws a verification image. Anyway, while implementing Alpha's code I did make a few slight modifications and I also discovered a bug which prevented it from working correctly on my 188.8.131.52 implementation. Since the original article was written in Chinese and then translated to English I thoug... [More]