Skip to content

Instantly share code, notes, and snippets.

@venblee
venblee / XML.sql
Created December 13, 2013 07:09
Select From XML
@TestResults XML = Null
CREATE TABLE #Test
{
TestId INT
}
INSERT INTO #Test(TestId)
SELECT c.value ('@TestId[1]' , 'INT' ) AS TestId
@venblee
venblee / Script
Created August 5, 2013 08:03
Bootstrap-ToolTip
<script>
$(document).ready(function ()
{
$("a").tooltip({
'selector' : '' ,
'placement' : 'bottom'
});
@venblee
venblee / Re-Order Tables HTML
Created June 27, 2013 14:38
Re-Order Tables
<h1>Sorting A Table With jQuery UI</h1>
<a href='http://www.foliotek.com/devblog/make-table-rows-sortable-using-jquery-ui-sortable/'>Make table rows sortable with jQuery UI</a>
<table id="sort" class="grid" title="Kurt Vonnegut novels">
<thead>
<tr><th class="index">No.</th><th>Year</th><th>Title</th><th>Grade</th></tr>
</thead>
<tbody>
<tr><td class="index">1</td><td>1969</td><td>Slaughterhouse-Five</td><td>A+</td></tr>
<tr><td class="index">2</td><td>1952</td><td>Player Piano</td><td>B</td></tr>
@venblee
venblee / Return a File
Created June 27, 2013 14:13
Returning a File from MVC Controller. Makes user you use <a> </a>
public ActionResult Download()
{
// Get the file content as string
string fileContent = GetCSVFileContent();
// Get the bytes for the dynamic string content
var byteArray = Encoding.ASCII.GetBytes(fileContent);
string fileName = "Download File in ASP.NET MVC with dynamic content.csv";
@venblee
venblee / GrandChildren
Created June 26, 2013 17:38
Including GrandChildren in .Include()
using (var db = new PmsContext())
{
var dbresult = new Models.PurchaseOrder();
dbresult = db.PurchaseOrders
.Include("PurchaseOrderDetail")
.Include("PurchaseStatus")
.Include("RequestedEmployee")
// GrandChildren
@venblee
venblee / AJAX Dropdownlist
Last active December 19, 2015 00:29
Using Select Viewmodel to preload and AJAX for calls
$('#PostalCitySelect').select2({
initSelection: function(element, callback) {
var data = { id: $("#Supplier.PostalCityId").attr("value"), text: $("#Supplier_PostalCity_City").attr("value") };
callback(data);
@* $.ajax('@Url.Action("SearchCityById", "Suppliers")', {
data: {
searchTerm: $("#Supplier_PostalCity_CityId").attr("value")
},
@venblee
venblee / Normal Dropdown
Last active December 18, 2015 21:38
Select2 - > SelectList with viewmodel , DropDown with preload values.
// ViewModel
public class test
{
public IEnumerable<SelectListItem> thelist { get; set; }
public int theitemid { get; set; }
}
@venblee
venblee / MVC JSON Controller
Last active December 18, 2015 20:59
Retriecing Tags From DB and PreLoad them
public JsonResult SearchCity(string searchTerm)
{
var city = _locationService.SearchCity(searchTerm);
var result = city.Select(a => new { id = a.Id, text = a.City });
return Json(result, JsonRequestBehavior.AllowGet);
}
@venblee
venblee / Returng JSON
Created June 23, 2013 05:55
Returing Json from MVC Conntroller
public JsonResult SearchCity(string searchTerm)
{
var city = _locationService.SearchCity(searchTerm);
var result = city.Select(a => new { id = a.Id, text = a.City });
return Json(result, JsonRequestBehavior.AllowGet);
}
@venblee
venblee / String CSV to List<int>
Created June 22, 2013 15:44
Split a String CSV into List
List<int> TagIds = new List<int>(tags.Split(',').Select(int.Parse));