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
| <!-- | |
| Requires the following Nuget packages: | |
| 1. MVCFlash | |
| 2. JQueryUI (combined) | |
| 3. Fancybox | |
| --> | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>@ViewBag.Title</title> |
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 class StringExtensions | |
| { | |
| public static bool IsNumeric(this String str) | |
| { | |
| double temp; | |
| return double.TryParse(str, out temp); | |
| } | |
| } |
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 Logger Class | |
| public static class Logger | |
| { | |
| public static void Log(string message) | |
| { | |
| File.AppendAllText("C:\\MyLogFile.txt", DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + ":\t" + message + Environment.NewLine); | |
| } | |
| } | |
| // Usage |
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
| DateTime now = DateTime.Today; | |
| int age = now.Year - bday.Year; | |
| if (bday > now.AddYears(-age)) age--; |
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
| --Reset identity to 0 | |
| DBCC CHECKIDENT('TableName', RESEED, 0) |
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
| //replace all but links | |
| /<(?!\/?a(?=>|\s.*>))\/?.*?>/g | |
| //validate url | |
| /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \?=.-]*)*\/?$/ | |
| //Validate US phone number | |
| /^(\+\d)*\s*(\(\d{3}\)\s*)*\d{3}(-{0,1}|\s{0,1})\d{2}(-{0,1}|\s{0,1})\d{2}$/ | |
| //Test if a password is strong |
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; | |
| using System.Collections.Generic; | |
| using System.ComponentModel; | |
| using System.ComponentModel.DataAnnotations; | |
| using System.Linq; | |
| [MetadataType(typeof (FooBarMetaData))] | |
| public class FooBar | |
| { | |
| // Insert FooBar related properties, methods, etc. here |
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 void LogException(string ErrorDescription) | |
| { | |
| // The name of our log in the event logs | |
| string Log = “AspNetError”; | |
| // Check to see fi the log for AspNetError exists on the machine | |
| // If not, create it | |
| if ((!(EventLog.SourceExists(Log)))) | |
| { |
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
| delegate string DelegateTest(string str); | |
| DelegateTest delTest = new DelegateTest(Class1.Hello); | |
| Console.WriteLine(delTest("LOL")); | |
| class Class1{ | |
| ... | |
| public static string Hello(string msg) { | |
| return "Hello " + msg; | |
| } |
OlderNewer