How to use JQuery dialog as Confirm dialog in ASP.NET

Another ASP.NET WebForms post. It seems I'm "stuck" with WebForms for now, so lets make the best out of it. Today's issue: how many times did you have to code some confirmation logic on your website to ensure that your users are (doubly/triply) sure about the action they are about to perform? A typical example is prompting the user to confirm that they are sure about deleting a record. In typical/boring javascript world, you would do something like this: HTML <asp:Button runat="server" ID="btnDelete" Text="Delete" …[read more]


Dependency Injection in ASP.NET WebForms with StructureMap

Ahhh, the beautiful world of Dependency Injection (DI) trying to find it's way back in ASP.NET WebForms. What is it with me and ASP.NET WebForms lately? Just when I think I left all this behind, more and more work is thrown my way using this technology. ASP.NET forms has been around for a while and will also be an integral part of "One ASP.NET", so it is not a lost skill after all. I'm currently working on a major migration project bringin a 1.1 ASP.NET website to the 21st century-ish. All the …[read more]


Upload files in ASP.NET MVC with JavaScript and C#.

In an earlier [post](GHOST_URL/upload-files-to-the-server-using-javascript-and-mvc-webapi/" target="_blank), I described how to implement a file upload using [Ajax](http://api.jquery.com/jquery.ajax/" target="_blank) and [ASP.NET WebAPI](http://www.asp.net/web-api" target="_blank). This works great but it means that you need to have a WebAPI controller to manage the requests. If you already have a WebAPI in your solution then you can simply extend it to manage file uploads. However, there's no reason to add a WebAPI only for file uploads. Instead you can use an MVC controller …[read more]


Extend the Common.Logging API with Log4Net

In an earlier post I described how the Common.Logging API can help us abstract logging in our application by hiding the implementation details and allowing us to use different logging providers (NLog, Log4Net etc) in a modular, plug-n-play way. In this post, we will examine how to combine Common.Logging with Log4Net in order to output log messages to a file. 1. Install the right NuGet packages in the right order Before beginning, I will assume that all your assemblies already implement the Common.Logging API. If not, then go through my post to see how to add logging …[read more]


My developer rig and why I use a MacBook Pro as a .NET developer

If you are like me, then you spend most of your day in front of your laptop/desktop and a couple of screens. So it makes sense that you use the best tools available to make your life and work easier. This was my goal when I decided to set up my home dev rig to ensure that I enjoy it as much as I can. So, what is my current setup and what tools do I use to make development as easy and enjoyable as possible? I will start with the hardware and then move on to software. 1. …[read more]


Processing Payments and with Stripe, JavaScript and C# - PCI compliant

The source code and post have been updated to use the latest Stripe.NET API => v4.2 Online payments! We've all used them and some of us may have had the "fortune" implementing them on one website or another. [Stripe](http://stripe.com" target="_blank") is the not-so-new kid on the block, since it recently expanded in many countries, that makes this development task a breeze. If you are using .NET, then [Stripe.NET](https://github.com/jaymedavis/stripe.net" target="_blank) is an excellent library that hides away most of the …[read more]


Upload files to the server using Javascript and MVC WebAPI

The ASP.NET WebAPI is really versatile and powerful and I like to use it as much as I can when I develop for the web. I know that MVC controller methods can also process ajax requests, but I like the separation of concerns. WebAPI for REST calls and MVC for Views and the ViewModels manipulation. Note: if you still want to use MVC instead of WebAPI for your server implementation, have a read here. Recently, I had to implement a method to upload files to the server from an MVC view. I decided to use ajax and WebAPI. Once …[read more]


How to bind an Enum to a DropDownList in ASP.NET MVC

Prior to ASP.NET MVC 5, the only way to bind an enum to a drop down list in an MVC view was to roll out your own HtmlHelper, which is the best way to extend MVC's functionality. These days, with MVC 5 at your disposal, you can bind any enum to a view control easily by calling the "oh so handy" EnumDropDownListFor HTML helper. Details on the helper can be found here and works like any other build in HTML helper, with a model, a model property and a bunch of additional attributes that allow you to …[read more]