Category: Development

  • C# Ordinal String Extension

    Let’s explore creating an extension method to convert a number to an ordinal value, e.g. 1st, 2nd, 3rd, etc.

    (more…)

  • Entity Framework’s Code-First with an ObjectContext

    If the following blog interests you, it’s probably because you’re using Entity Framework with a Code-First approach and whatever it is you are trying to do *must* use an ObjectContext instead of the standard DbContext. I’m sure, like me, you thought this shouldn’t be too hard. Then you started hitting roadblocks like, Metadata is required in your connection string. What’s metadata? This is only needed in Database-First so you can tell the framework where your edmx and other definition files are, so why do I need this with Code-First, I don’t have these files?

    This was definitely my first reaction as well. So after much trial-and-error and research, I have the solution!

    (more…)

  • Checking if an element exists with jQuery

    You want to do some conditional processing depending on if an item or items exist in your DOM (Document Object Model). By default, jQuery doesn’t have a function that performs this; however, there is a very simple way to extend jQuery to do so.

    (more…)

  • Posting form variables that are not strongly typed with MVC

    In a lot of the MVC 3 examples that are available on the Internet today, they are quite typically strongly typed to a model, e.g. public ActionResult LogOn(LogOnModel model, string returnUrl).

    This is extremely useful for the validation abilities and many other aspects; however, there are times when some or all of the data is not strongly typed; then what do you do? Read on for two different approaches.

    (more…)

  • Creating Your Own jQuery Selector

    By default, the jQuery selectors are pretty advanced. You can select items by classes, ids, attributes, the first, the last, etc… But why stop there? By simply extending jQuery, we can add our own custom selectors to further enhance how we use jQuery. In this example, I will create an extended function called widthOver300 leveraging jQuery’s $.extend

    (more…)