This file contains hidden or 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
function inputLimiter(e, allow, value) { | |
var AllowableCharacters = ''; | |
if (allow == 'Letters') { AllowableCharacters = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; } | |
if (allow == 'Numbers') { AllowableCharacters = '1234567890'; } | |
if (allow == 'NameCharacters') { AllowableCharacters = ' ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.\''; } | |
if (allow == 'NameCharactersAndNumbers') { AllowableCharacters = '1234567890 ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-\''; } | |
var k; | |
k = document.all ? parseInt(e.keyCode, 10) : parseInt(e.which, 10); | |
if (k != 13 && k != 8 && k !== 0) { | |
if ((e.ctrlKey === false) && (e.altKey === false)) { |
This file contains hidden or 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
function roundNumber(number, decimal_points) { | |
if (!decimal_points) return Math.round(number); | |
if (number === 0) { | |
var decimals = ""; | |
for (var i = 0; i < decimal_points; i++) decimals += "0"; | |
return "0." + decimals; | |
} | |
var exponent = Math.pow(10, decimal_points); | |
var num = Math.round((number * exponent)).toString(); |
This file contains hidden or 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
from p in PersonOrders | |
// put your where clause here | |
group p by p.PersonID into grp //could be grouped by anything, Grouping on Guid ID's is not a good idea | |
let MaxOrderDatePerPerson = grp.Max ( g=>g.OrderDate ) | |
from p in grp | |
where p.OrderDate == MaxOrderDatePerPerson | |
select p |
This file contains hidden or 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
protected void ProcessImageAndItsThumbnail(string url) | |
{ | |
//make memory streams to work with the image bytes | |
MemoryStream imageStream = new MemoryStream(); | |
MemoryStream thumbStream = new MemoryStream(); | |
//using, so resources get disposed automagically | |
//using the uploaded image (which might be huge) | |
using (System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath(url))) | |
{ |
This file contains hidden or 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
public static bool IsNumeric(this string s) | |
{ | |
double d = 0.0; | |
return (double.TryParse(s, out d)); | |
} | |
public static int? ToIntegerNullable(this string s) | |
{ | |
int i = 0; | |
if (int.TryParse(s, out i)) |
This file contains hidden or 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
public static XElement Serialize(this object o) | |
{ | |
XElement e = new XElement("property"); | |
PropertyInfo[] properties; | |
Type _t = o.GetType(); | |
properties = _t.GetProperties(); | |
if (properties.Length == 0) //This implies that it is a VALUE TYPE | |
e.SetValue(o); |
This file contains hidden or 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.IO; | |
using System.Web; | |
using System.Web.UI; | |
using System.Web.UI.WebControls; | |
/// <summary> | |
/// Exports a GridView with its contents to a CSV file | |
/// </summary> | |
public class GridViewExportUtil | |
{ |
This file contains hidden or 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
/// <summary> | |
/// This will return a camel-cased string, so that it reads as a normal string, by adding a space before each capital letter. | |
/// </summary> | |
public static string SpaceOutCamelCasing(this string theWord) | |
{ | |
char[] temp = theWord.ToCharArray(); | |
string Result = ""; | |
foreach (char c in temp) | |
if (c.ToString() == c.ToString().ToUpper()) |
This file contains hidden or 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
// The problem is when you have a table, | |
// which gets cut in half at the botto of one page, | |
// and the other half shows up at the top of the next page. | |
// To prevent this, you can wrap your table in a container table (with a single cell) | |
PdfPTable containerTable = new PdfPTable(1); | |
containerTable .WidthPercentage = 100; | |
PdfPCell containerTableCell = new PdfPCell(); |