ASP.net Utils File
I've just uploaded the latest version of the ASP.Net toolbox (version 2.0). This is a small .cs file that you can put in your app_code folder and contains some really useful helper functions
The toolbox file contains the following helper static functions:
- isNumeric - evaluates whether a string is a number
- isDate - tests whether a string is a valid date
- isValidEmail - checks whether a string conforms to a valid email address format
- isValidURL - checks whether a string is a valid url
- CreateRandomPassword - generates a random password
- CountStringOccurrences - counts the number of times a pattern appears in a string
- GetIP - returns the ip address of a visitor.
- FindControlRecursive - Recursive find control for HTMLGenericControls - you can modify this method to other types of controls if required.
Download the toolbox helper file here: http://www.mykeblack.com/data/files/mykeblack.txt (right click on this link and select 'save as')
(Important: once you have downloaded the text file, rename it to 'mykeblack.cs' - Due to security restritions, you cannot download .cs files from a windows server.)
To use the toolbox for your asp.net page, do the following:
- Copy the file into your app_code folder
-
At the top of your .cs page (or your .aspx page if you are not using a separate code behind page) reference the namespace like this:
using MykeBlack;
-
In your code, call the functions eg like this:
string myString = "1234567";
if ( ToolBox.IsNumeric(myString,true) {
// myString is a valid number
}
