Skip to content

Instantly share code, notes, and snippets.

View johnnyreilly's full-sized avatar

John Reilly johnnyreilly

View GitHub Profile
@johnnyreilly
johnnyreilly / BootstrapBundleConfig.cs
Last active December 11, 2015 02:09
Twitter.Bootstrap.MVC4 meet Bootstrap Datepicker - now with Internationalization
using System;
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Globalization;
using System.IO;
using System.Linq;
namespace BootstrapSupport
{
@johnnyreilly
johnnyreilly / BootstrapBundleConfig.cs
Created January 14, 2013 12:32
Twitter.Bootstrap.MVC4 meet Bootstrap Datepicker
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
namespace BootstrapSupport
{
public class BootstrapBundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
@johnnyreilly
johnnyreilly / FieldValidationAfter.cs
Last active December 13, 2015 16:59
Showing how to use expressions with constructors to drive strongly typed validation.
public class FieldValidation
{
public FieldValidation(string fieldName, string message)
{
FieldName = fieldName;
Message = message;
}
public string FieldName { get; set; }
public string Message { get; set; }
@johnnyreilly
johnnyreilly / HowIsItUsed.cs
Created February 14, 2013 13:06
jQuery UI Autocomplete meet Coded UI Tests
// Find the autocomplete input text element
var autocompleteInput = new UITestControl(Browser);
autocompleteInput.TechnologyName = "Web";
autocompleteInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "myAutocomplete");
autocompleteInput.Find();
// Find the UL based on the autocomplete input text element
var ul = autocompleteInput.GetAutocompleteUl();
@johnnyreilly
johnnyreilly / DemoAreaRegistration.cs
Last active October 29, 2019 13:43
What you need to unit test MVC controllers using MOQ.
using System.Web.Mvc;
namespace DemoApp.Areas.Demo
{
public class DemoAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
@johnnyreilly
johnnyreilly / CarController.cs
Last active November 6, 2023 22:05
Unit testing ModelState using Moq
using System.Web.Mvc;
namespace MyApp
{
public class CarController : Controller
{
//...
public ActionResult Edit(CarModel model)
{
@johnnyreilly
johnnyreilly / DecimalModelBinder.cs
Last active July 27, 2017 09:37
Phil Haacks DecimalModelBinder adapted to handle nullable decimals
using System;
using System.Globalization;
using System.Web.Mvc;
namespace My.ModelBinders
{
/// <summary>
/// Thank you Phil Haack: used to model bind multiple culture decimals
/// http://haacked.com/archive/2011/03/19/fixing-binding-to-decimals.aspx
///
@johnnyreilly
johnnyreilly / any.html
Last active December 15, 2015 15:39
Death to compatibility mode
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- See how the meta tag is the first inside the head? That's *important* -->
</head>
<body>
</body>
</html>
@johnnyreilly
johnnyreilly / ie10jQueryUI.css
Last active December 16, 2015 00:09
Making IE 10's clear field ("X") button and jQuery UI play nice
/* jQuery auto completes add the class below when loading */
.ui-autocomplete-loading {
background:url('/images/ajax_loader.gif') no-repeat right 0.5em center;
}
/* How'd you like them apples IE 10? */
.ui-autocomplete-loading::-ms-clear {
display: none;
}
@johnnyreilly
johnnyreilly / CassetteConfiguration.cs
Last active December 16, 2015 06:48
How to use Cassette in an ASP.Net project
using Cassette;
using Cassette.Scripts;
using Cassette.Stylesheets;
namespace CassetteDemo
{
/// <summary>
/// Configures the Cassette asset bundles for the web application.
/// </summary>
public class CassetteBundleConfiguration : IConfiguration<BundleCollection>