This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A bi-directional infinite scrolling jQuery plugin | |
// | |
// Usage Example: | |
// $(window).infiniteScroll({ url: window.location.href }) | |
(function($) { | |
$.scroller = { | |
// default settings | |
settings: { | |
url: null, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// Support for AJAX loaded modal window. | |
// Focuses on first input textbox after it loads the window. | |
$('[data-toggle="modal"]').click(function(e) { | |
e.preventDefault(); | |
var url = $(this).attr('href'); | |
if (url.indexOf('#') == 0) { | |
$(url).modal('open'); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In the ViewModel or Controller, create a new TotalWebGrid and return it to the view, just like with the normal WebGrid. | |
public TotalWebGrid Grid | |
{ | |
get | |
{ | |
return new TotalWebGrid( | |
source: stagingBillLines, | |
rowsPerPage: 10, | |
ajaxUpdateContainerId: "BillLines"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AcceptVerbs(HttpVerbs.Post)] | |
public ActionResult UploadImage(HttpPostedFileBase upload, string CKEditorFuncNum, string CKEditor, string langCode) | |
{ | |
//http://stackoverflow.com/a/4088194/167670 | |
//http://arturito.net/2010/11/03/file-and-image-upload-with-asp-net-mvc2-with-ckeditor-wysiwyg-rich-text-editor/ | |
//http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx | |
if (upload.ContentLength <= 0) | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('your-module').config(['$provide', function ($provide) { | |
$provide.decorator('$rootScope', ['$delegate', function ($delegate) { | |
wrapMethod($delegate, '$broadcast', function (method, args) { | |
if (isNonSystemEvent(args[0])) | |
logCall('$broadcast', args); | |
return method.apply(this, args); | |
}); | |
wrapMethod($delegate, '$emit', function (method, args) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build zip file | |
using (var zip = new ZipFile(zipFilePath)) | |
{ | |
zip.AddDirectory("Zip files go here"); | |
zip.Save(zipFilePath); | |
} | |
//create upload package | |
var uploadData = new NewObjectThatGoesAlongWithTheFile(SomeDataToCreateObject); | |
uploadData.ResultFileMd5 = CalculateMd5(zipFilePath); //calculate an md5 to compare on the other side |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Data.Entity; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Net.Http; | |
using System.Net.Http.Handlers; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//in setup define client and progress reporter | |
var httpProgressHandler = new ProgressMessageHandler(); | |
httpProgressHandler.InnerHandler = new HttpClientHandler(); | |
var client = new HttpClient(httpProgressHandler) { BaseAddress = new Uri(Settings.Default.ServerUrl) }; | |
//register to use elsewhere in the application, note it is better to resuse for lifetime of application than create for every call | |
Mvx.RegisterSingleton(client); | |
Mvx.RegisterSingleton(httpProgressHandler); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Retry http with a back off on failure | |
await Policy.Handle<HttpRequestException>().WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))) | |
.ExecuteAsync(async () => | |
{ | |
var result = await httpClient.GetAsync("api/CallToServer/" + varibleToSendToServer, cancellationToken); | |
if (result.IsSuccessStatusCode) | |
{ | |
returnValue = await result.Content.ReadAsAsync<List<Results>>(token); | |
} |
OlderNewer