Skip to content

Instantly share code, notes, and snippets.

@weedkiller
weedkiller / SelectListExtensionMethods.cs
Created January 21, 2018 21:44 — forked from nickalbrecht/SelectListExtensionMethods.cs
SelectListItem Extension Methods for DropDowns in MVC Core. Added ability to specify the option's Group, and for some bug fixes, more XML docs
void Main()
{
}
// Define other methods and classes here
public static class SelectListExtensionMethods
{
/// <summary>
/// The SelectListItem to use by default as the placeholder for any select lists generated by these extension methods.
@weedkiller
weedkiller / SelectListExtensionMethods.cs
Created January 21, 2018 21:44 — forked from mombrea/SelectListExtensionMethods.cs
SelectListItem Extension Methods for DropDowns in MVC, Updated comments for better intellisense
public static class SelectListExtensionMethods
{
//// simple Enum for demonstration in the examples
//enum Colors {
// Red = 1,
// Green = 2,
// Blue = 3
//}
//// Simple Class for demonstration in the examples
@weedkiller
weedkiller / SelectListExtensionMethods.cs
Created January 21, 2018 21:44 — forked from mombrea/SelectListExtensionMethods.cs
SelectListItem Extension Methods for DropDowns in MVC, Updated comments for better intellisense
public static class SelectListExtensionMethods
{
//// simple Enum for demonstration in the examples
//enum Colors {
// Red = 1,
// Green = 2,
// Blue = 3
//}
//// Simple Class for demonstration in the examples
@weedkiller
weedkiller / SortSearchExtensions.cs
Created January 21, 2018 21:43 — forked from mombrea/SortSearchExtensions.cs
Extension Methods for table sorting and search query
using System.Collections.Specialized;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace My.App
{
public static class Extensions
{
/// <summary>
@weedkiller
weedkiller / jQuery.antiforgerytoken.js
Created January 10, 2018 09:52 — forked from scottrippey/jQuery.antiforgerytoken.js
ASP.NET MVC AntiForgeryToken + AJAX = jQuery to the rescue
// Setup CSRF safety for AJAX:
$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
if (options.type.toUpperCase() === "POST") {
// We need to add the verificationToken to all POSTs
var token = $("input[name^=__RequestVerificationToken]").first();
if (!token.length) return;
var tokenName = token.attr("name");
namespace ExampleProject.Controllers
{
public class HomeController : Controller
{
[HttpGet]
public ActionResult Index()
{
return View();
}
@weedkiller
weedkiller / Cross Table Drag Drop.html
Created July 28, 2017 03:34 — forked from davemo/Cross Table Drag Drop.html
This works for dragging, dropping table rows between two separate tables across most browsers :)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="David Mosher">
<!-- Date: 2010-11-18 -->

1. Clone your fork:

git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
// Single Key
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => customer.Code);
// Surrogate Key (with anonymous type)
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => new { customer.Code1, customer.Code2, customer.Code3 });
// DON'T add the key if auto-generated
ctx.BulkInsert(customers, operation => operation.ColumnInputExpression =
customer => new {customer.Name, customer.Email});
// ALWAYS add the key
ctx.BulkUpdate(customers, operation => operation.ColumnInputExpression =
customer => new { customer.ID, customer.Name, customer.Email });
// ALWAYS add the key
ctx.BulkMerge(customers, operation => operation.ColumnInputExpression =