Skip to content

Instantly share code, notes, and snippets.

View weslley39's full-sized avatar
🤘
Awesome

Weslley Neri weslley39

🤘
Awesome
View GitHub Profile
public class WebApiApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
// *** Other Configurations ***
UnityConfiguration(GlobalConfiguration.Configuration);
}
public void UnityConfiguration(HttpConfiguration httpConfiguration)
$.ajaxSettings.traditional = true; // <-- Important
$('#btn').click(function () {
var array = [];
var url = '/Controller/Action';
$.post(url, { array : array });
});
});
@weslley39
weslley39 / isNumberKey
Last active August 29, 2015 13:56
Verify is the key pressed is a number, if not, deletes the word
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
@weslley39
weslley39 / isLetterKey
Last active August 29, 2015 13:56
Verify is the key pressed is a letter, if not, deletes the number
function isLetterKey(evt)
{
evt = (evt) ? evt : event;
var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode :
((evt.which) ? evt.which : 0));
if (charCode > 31 && (charCode < 65 || charCode > 90) &&
(charCode < 97 || charCode > 122)) {
return false;
}
return true;
@weslley39
weslley39 / UnityDependencyResolver
Created February 19, 2014 16:53
UnityDependencyResolver
using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Microsoft.Practices.Unity;
namespace Ukutool
{
public class UnityDependencyResolver : IDependencyResolver
{
private readonly IUnityContainer _container;
@weslley39
weslley39 / Js Load After Page Has Loaded
Last active August 29, 2015 13:56
Run JavaScript Only After Entire Page Has Loaded
$(window).bind("load", function() {
// code here
});
@weslley39
weslley39 / Force_Download
Created February 27, 2014 15:31
Forcing download of a type in Asp Mvc C#
var bytes = Encoding.UTF8.GetBytes(sb.ToString());
Stream stream = new MemoryStream(bytes);
stream.Flush();
stream.Position = 0;
Response.ContentType = "text/plain";
Response.AppendHeader("content-disposition", "attachment;filename=exportacao");
return new FileStreamResult(stream, "text/plain");
@weslley39
weslley39 / Asp Mvc Date to Js Date
Created March 5, 2014 19:05
Asp Mvc Date to Js Date
var mili = Data.replace('Date', '').replace('/', '').replace('(', '').replace(')', '').replace('/', '');
var dataJavascript = new Date(eval(mili));
var realDate = dataJavascript.toLocaleDateString();
value.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1.")
@weslley39
weslley39 / Verify_Email
Created March 10, 2014 15:08
verify if is an emaill with jaavscript in asp mvc
var emailRegExp = /^[A-Z0-9._%+-]+@@[A-Z0-9.-]+\.[A-Z]{2,4}$/i;
var validaEmail = emailRegExp.test(input.val());