lunes, 25 de febrero de 2013
Page loaded in javascript
Using anonimus function (due to the scope) the events fire where the page is loaded.
lunes, 18 de febrero de 2013
Simple Context Menu in Javascript
Right click to get a custom context menu. Click anywhere else to get the default context menu.
domingo, 17 de febrero de 2013
Working with Keycodes in Javascript
I've dicovered a new way for working with keycodes in javascript. Here is the code:
jueves, 14 de febrero de 2013
Extend class String with Trim function in javascript
String.prototype.trim = function () { return this.replace(/^\s+/, '').replace(/\s+$/, ''); }
Authentication SharePoint 2010 based in Forms
using Microsoft.SharePoint; using Microsoft.SharePoint.IdentityModel; public class AuthenticationSharePoint : Authentication { public bool IsValid( string url, Usuario usuario) { return SPClaimsUtility.AuthenticateFormsUser(new Uri(url), usuario.Login, usuario.Contrasenia); } }
Clone Generic Object by Reflection in .NET
public static ListGetAllProperties(Type type) { BindingFlags flags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly; var list = new List (); if (type != null) { list.AddRange(type.GetProperties(flags)); list.AddRange(GetAllProperties(type.BaseType)); } return list; } public static T Clonar (T original) { if (original == null) { throw new Exception("cannot be null object"); } var tipo = original.GetType(); var resultado = Activator.CreateInstance(tipo); foreach (PropertyInfo propiedad in GetAllProperties(tipo)) { propiedad.SetValue(resultado, propiedad.GetValue(original, null), null); } return (T)resultado; }
lunes, 11 de febrero de 2013
domingo, 10 de febrero de 2013
Load CSS file Dynamically
function loadCSSFileDymanically(dir){ var link = document.createElement(“link”); link.rel = "stylesheet"; link.type = "text/css"; link.href = dir; var head = document.getElementsByTagName(“head”)[0]; head.appendChild(link); }
Load JavaScript file Dynamically
function loadScriptDinamically(dir){ var script = document.createElement(“script”); script.type = “text/javascript”; script.src = dir; document.body.appendChild(script); }
Suscribirse a:
Entradas (Atom)