 |
DateTime.ToString() Patterns
Paul Hayman (90347 views)
DateTime.ToString() Patterns
All the patterns:
||0|| MM/dd/yyyy|| 08/22/2006 ||
||1|| dddd, dd MMMM yyyy|| Tuesday, 22 August 2006 ||
||2|| dddd, dd MMMM yyyy|| HH:mm Tuesday, 22 August 2006 06:30 ||
||3|| dddd, dd MMMM yyyy|| hh:mm tt Tuesday, 22 August 2006 06:30 AM ||
||4|| dddd, dd
|
 |
Launching an Atlas ModalPopupExtender from JavaScript
Paul Hayman (30658 views)
Launching an Atlas ModalPopupExtender from JavaScript
{Looking for an '''Ajax version''' of this article??}http://www.geekzilla.co.uk/View38736C2B-BAD3-418A-A5B0-DAC4F1A5A83A.htm
Looking round the web there are some crazy ways people are trying to launch the ModalPopupExtender from JavaScrip
|
 |
Creating a Tag Cloud in C#
Paul Hayman (24906 views)
Creating a Tag Cloud in C#
I wanted to add a TagCloud to GeekZilla. The first thing I did was look around the web for some examples (or free components). To my supprise none jumped out at me. So, I decided to write my own.
At first I found myself wondering how I would render different size w
|
 |
Using Regular Expressions to validate a filename in a FileUpload control
Paul Hayman (18054 views)
Using Regular Expressions to validate a filename in a FileUpload control
Here's a little code snippet I use to ensure that the file that has been uploaded is of type JPG, JPEG, PNG or GIF
#c#// check anything has been uploaded
#c#if (ThumbnailImageUpload.PostedFile.ContentLength > 0)
#c#{
|
 |
URL Regular Expression
Paul Hayman (16589 views)
URL Regular Expression
#c#string pattern = @"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)"
#c#
|
 |
IsGuid() (Regular Expression Guid Match)
Paul Hayman (11941 views)
IsGuid() (Regular Expression Guid Match)
A regular expression for validating a string as being a Guid is..
#c#@"^(\{{0,1}([0-9a-fA-F]){8}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){4}-([0-9a-fA-F]){12}\}{0,1})$"
#c#
Example usage
Below is a function I try to keep handy which tests
|
 |
Launching an Ajax ModalPopupExtender from JavaScript
Paul Hayman (11747 views)
Launching an Ajax ModalPopupExtender from JavaScript
This is an updated version of the earlier (and very popular) {Atlas article}http://www.geekzilla.co.uk/ViewDAAE6AAB-0369-45C2-BE78-B8E6F876B4F4.htm
It is by far the simplest way to launch an Ajax ModalPopupExtender from javascript.
The
|
 |
IP Address regular expression
Paul Hayman (11686 views)
IP Address regular expression
#c#string pattern = @"\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"
#c#
|
 |
Writing CLR Stored Procedures in C#
Paul Hayman (10997 views)
Writing CLR Stored Procedures in C#
As SQL Server 2005 rolls out DBA's are going to be forced to learn either C# or Visual Basic or both. Until now these were client side languages and not knowing them had little impact on your job. And if you write code in these languages your going to have to
|
 |
Backup ALL your SQL Server 2005 databases using ONE script
Paul Hayman (10940 views)
Backup ALL your SQL Server 2005 databases using ONE script
I wanted to backup all my databases... I had loads, creating a step for each db was getting tedious, so I wrote this script.
Enjoy
#s#DECLARE @DBName varchar(255)
#s#
#s#DECLARE @DATABASES_Fetch int
#s#
#s#DECLARE DATABASES_
|
 |
Google Applicance - googleoff / googleon Tags
Paul Hayman (10355 views)
Google Applicance - googleoff / googleon Tags
'''I came across these recently... thought I'd share''' ;)
The googleoff/googleon tags disable the indexing of a part of a web page. The result is that those pages do not appear in search results when users search for the tagged word or phrase. F
|
 |
A simple guide to creating your first Vista Gadget
Paul Hayman (9620 views)
A simple guide to creating your first Vista Gadget
Gadgets are simply HTML and JavaScript. The SideBar exposes a bunch of API's which are accessible from JavaScript and extends the HTML schema. In this short guide we will greate a simple "Hello World" gadget.
The four steps
*Create a dir
|
 |
Highlighting keywords in text using Regex.Replace (Perfect for SEO)
Paul Hayman (9426 views)
Highlighting keywords in text using Regex.Replace (Perfect for SEO)
Why
I needed to take some text and bold certain keywords before returning the data to the web browser to enhance my {Search Engine Optimization}http://www.kwiboo.com/SearchEngineOptimisation.aspx
Example
The followi
|
 |
Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()
Paul Hayman (7922 views)
Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()
It's common knowledge that a control, when '''Runat="server"''' will resolve it's src or href attribute to a virtual root when the URL starts with '''~/'''
For example:
#h#<a href="~/Customers/Profile.aspx" Runat="serv
|
 |
Enabling TRUSTWORTHY on a SQL 2005 Database
Paul Hayman (7171 views)
Enabling TRUSTWORTHY on a SQL 2005 Database
If your .NET stored procedure wants to have external access, the targer database will have to have TRUSTWORTHY set on.. this is how you do it.
#c#ALTER DATABASE databasename SET TRUSTWORTHY ON;
#c#GO
|
 |
CLR Stored Procedure for searching files
Paul Hayman (7030 views)
CLR Stored Procedure for searching files
I was recently asked to write a CLR stored procedure which would process a text file and return a row for each line in the file that contained text matching our search criteria.
I'd never written a CLR stored proc before so it was an interesting learn
|
 |
Calling a static "page method" from Javascript using MS AJAX
Paul Hayman (6911 views)
Calling a static "page method" from Javascript using MS AJAX
Atlas gave us the ability to easily call Web Services from JavaScript. MS AJAX has gone one step further We can now call methods in the codebehine of the current page from Javascript. Here's how:
'''This is designed for v1.0.61025
|
 |
Triple DES encryption wrapper
Paul Hayman (6773 views)
Triple DES encryption wrapper
Here is a handy wrapper for Triple DES encryption:
#c#using System;
#c#using System.Collections.Generic;
#c#using System.Text;
#c#using System.Security.Cryptography;
#c#using System.IO;
#c#
#c#namespace Security
#c#{
#c# /// <summary>
#c# /// Wrap
|
 |
What screen size should we be building sites for?
Paul Hayman (6420 views)
What screen size should we be building sites for?
With high resolution screens becoming increasingly cheaper to buy, what screen size should we really be building websites for?
I took some stats from GeekZilla (in google analytics) and was pleased to find that the most popular was reasonable
|
 |
Could not write to output file ... The directory name is invalid
Paul Hayman (6319 views)
Could not write to output file ... The directory name is invalid
Recently had a problem deploying an app to a fresh 2003 server. Basically, the application wouldn't start, instead we recieved an error stating that the compiler couldn't write to the '''"Temporary ASP.NET Files"''' folder because
|
 |
Adding a transparent background to a Vista Gadget
Paul Hayman (6047 views)
Adding a transparent background to a Vista Gadget
Adding a transparent background to a gadget is easy Simply create a transparent .png file and reference it from your Gadget HTML.
Here is an example file (also attached to this article as a download):
[[background.gif]]
Here is the HTM
|
 |
Enabling Service Broker
Paul Hayman (5775 views)
Enabling Service Broker
The following T-Sql enables or disabled service broker on SqlServer 2005. The Service Broker is required by .net for SqlCacheDependency support
#s#-- Enable Service Broker:
#s#ALTER DATABASE [Database Name] SET ENABLE_BROKER;
#s#
#s#-- Disable Service Broker:
#s#A
|
 |
Restricting the number of rows in a dataview when binding to a repeater
Paul Hayman (5533 views)
Restricting the number of rows in a dataview when binding to a repeater
The problem
I needed to restrict the number of items bound to an '''asp:repeater'''. Basically I never wanted more than 10 items to be displayed.
Options
The right thing to do would be to restrict the number of it
|
 |
Sorting an XML document in C# using XSL
Paul Hayman (4922 views)
Sorting an XML document in C# using XSL
I needed to sort some XML in C# before itterating through the document. In the end I used the XslCompiledTransform to apply an XSL stylesheet to the XML document. Works very quickly. For reference, this is how I did it.
The code
The following uses
|
 |
Reading a file which is locked by another process
Paul Hayman (4689 views)
Reading a file which is locked by another process
The following code snippet shows how to read a file which is locked by another process..
#c#FileStream logFileStream = new FileStream("c:\test.txt", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
#c#StreamReader logFileReader = new S
|
 |
Web 2 Ajax Style Animated Gif's
Paul Hayman (4644 views)
Web 2 Ajax Style Animated Gif's
When searching high and low for a ajax style wait icon I came across the following sites.
The first is a very good source of {web 2}http://www.kwiboo.com/web2.aspx style animated gifs:
http://www.sanbaldo.com/wordpress/1/ajax_gif/ - Example: [[bigrotation2.
|
 |
DTS, Excel and mixed format columns
Paul Hayman (4386 views)
DTS, Excel and mixed format columns
I recently had a problem DTS importing an Excel spreadsheet which contained columns with mixed text and data values. After a bit of hunting around, I found an extended property IMEX=1. The IMEX=1 property forces everything to text when reading from a source.
|
 |
Installing XNA Beta
Paul Hayman (4183 views)
Installing XNA Beta
Ok, I thought I'd document the installation process and any pitfalls I encountered. I decided to install XNA on a VMWare machine, just to keep things clean, '''this didn't work''' as XNA couldn't detect an appropriate Direct3d compatible graphics card, so I installed it on t
|
 |
Using a DataSet as a return type on an Atlas Javascript WebService call
Paul Hayman (4038 views)
Using a DataSet as a return type on an Atlas Javascript WebService call
If the WebService you are calling returns a DataSet it may not be obvious how to get to the data in the returned object.
Here is a little example which may help you on your way..
#h#<script language="javascript">
#
|
 |
Returning a value from a PageMethod
Paul Hayman (3774 views)
Returning a value from a PageMethod using MS AJAX
'''NOTE: This is designed for v1.0.61025.0 of AJAXExtensionsToolbox.dll'''
If you've ever returned data from a web service using MS AJAX this technique will look familar.
Call the method from javascript by append PageMethods. to the front
|
 |
Custom Templated SiteMap Navigator Control
Paul Hayman (3758 views)
Custom Templated SiteMap Navigator Control
After discovering the power of the SiteMap, especially when linked to Authentication, it wasn't long before binding the TreeView to the map was not enough.
I needed to have total control over what was displayed to the user for each item, so I wrote
|
 |
Handy Keyboard Shortcuts for c# 2005
Paul Hayman (3592 views)
Handy Keyboard Shortcuts for c# 2005
The following keyboard shortcuts I find invaluable. It's amazing how many people still use the mouse to do everything.
Document navigation
||Ctrl+Tab|| Switch documents||
||Ctrl+Shift+Tab|| Reverse switch documents||
||Ctrl+kk|| Drop a bookmark||
||
|
 |
Remembering position of DragOverlayExtender with Profile
Paul Hayman (3566 views)
Remembering position of DragOverlayExtender with Profile
You can get Atlas to store the last known position of your floating panel in the profile.
Three things you need to do to get this to work.
ProfileScriptService
In the page with the DragOverlayExtender you'll need to add a atlas
|
 |
Calling a WebService (from JavaScript) with Atlas
Paul Hayman (3531 views)
Calling a WebService (from JavaScript) with Atlas
This is too easy and damn powerful WebServices can be called from JavaScript directly once the service is registered in the Script Manager.
Script Manager
Add your service to the manager as seen below:
#h#<atlas:ScriptManager runat="serv
|
 |
Centering a DIV using the negative margin method
Paul Hayman (3435 views)
Centering a DIV using the negative margin method
The following CSS will center a DIV whih is 500px wide. This method is very clean and works in all browsers.
#c#div {
#c# position: absolute;
#c# left: 50%;
#c# width: 500px;
#c# margin-left: -250px;
#c#}
Change the width to suit your
|
 |
class.Serialize()
Paul Hayman (3284 views)
class.Serialize()
Handly little function which I include in most classes. This function returns the object serialized as XML, perfect for logging etc.
#c#/// <summary>
#c#/// Serialize this object
#c#/// </summary>
#c#/// <returns>XmlDocument containing the current information serialized<
|
 |
How to turn on automatic logon in Windows XP
Paul Hayman (3219 views)
How to turn on automatic logon in Windows XP
Original : http://support.microsoft.com/kb/315231
INTRODUCTION
This article describes how to configure Microsoft Windows XP to automate the logon process by storing your password and other pertinent information in the registry database. This fe
|
 |
Why not on by defaut? Turn on auto HTML attribute quotes in 2005
Paul Hayman (3053 views)
Why not on by defaut? Turn on auto HTML attribute quotes in 2005
Holy cow Why wasn't this on by default??? How annoying is it that when typing in the HTML Source editor window Visual Studio doesn't add the "" for you automatically?? If it's going to complain profusely about the missing quotes
|
 |
Programmatically adding LINKs to HTML HEADER in Code Behind
Paul Hayman (3046 views)
Programmatically adding LINKs to HTML HEADER in Code Behind
In this example I am adding a link to the html header pointing to an rss feed.
#c#HtmlLink link = new HtmlLink();
#c#link.Attributes.Add("type", "application/rss+xml");
#c#link.Attributes.Add("rel", "alternate");
#c#link.Attribut
|
 |
ISBN Number regular expression
Paul Hayman (2980 views)
ISBN Number regular expression
#c#string pattern = @"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$";
Examples
#c#// Valid
#c#Console.WriteLine(Regex.IsMatch(@"ISBN 0 93028 923 4", @"ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$"));
#c#
#c#// Valid
#c#Console.Wr
|
 |
Using Regex.Replace
Paul Hayman (2966 views)
Using Regex.Replace
Say you want to get the username from a fully qualified username such as '''MyDomain\AUser'''
Most developers would turn to SubString and LastIndexOf functions .. for example
#c#string userName = @"MyDomain\AUser";
#c#string result = userName.SubString(userName.LastInde
|
 |
Fixing broken users after Database Restore
Paul Hayman (2762 views)
Fixing broken users after Database Restore
Ever restored a Database which was created on a different server then not been able to use the same logon you had previously set up?
This command fixes the problem with the account.
#s#-- Replace username with the account to fix
#s#sp_change_users
|
 |
ASP.NET Framework 1.1 Validation not working in IE7?
Paul Hayman (2724 views)
ASP.NET Framework 1.1 Validation not working in IE7?
I recently had a problem with an old '''Framework 1.1''' website where the form would not post back if the page contained validators (CustomValidators to be exact). It caused me to do a lot of googling and in the end some javascript debugging
|
 |
Using Regex Look Arounds
Paul Hayman (2686 views)
Using Regex Look Arounds
.net supports four types of "Look Around". These can be used to make sure that patterns do or do not appear before or after whatever it is you're matching on. Consider the following text:
#c#"my car will be off the road for 2 days. it's reg num is ab123abc"
If I w
|
 |
How to get more than 3GB in Windows Vista 32-bit
Paul Hayman (2681 views)
How to get more than 3GB in Windows Vista 32-bit
Out if the box, Vista (32-bit) only detects a maximum of 3GB of RAM. You're probably gutted if you just bought a 4GB PC.
Vista 32-bit systems can actually detect 4GB RAM (and more). Sometimes the O.S. does not see the 4th GB of RAM but that c
|
 |
Evaluating Expressions
Paul Hayman (2625 views)
Evaluating Expressions
You can evaluate sums in the fly using .net DataTables.
This is how you do it (C# 2005).
#c#string sum = "(1+2)/4";
#c#System.Data.DataTable evaluator = new System.Data.DataTable("temp");
#c#double result;
#c#
#c#result = (double)evaluator.Compute(sum, null);
|
 |
Getting the Virtual Path of a Request in c#
Paul Hayman (2557 views)
Getting the Virtual Path of a Request in c#
This simple bit of code will get you the '''Virtual Path''' of your current request.
#c#public static string GetVirtualPath(string url)
#c#{
#c# if (HttpContext.Current.Request.ApplicationPath == "/")
#c# {
#c# return "~" + url;
#
|
 |
Regex match html content without screwing up the tags
Paul Hayman (2437 views)
Regex match html content without screwing up the tags
When needing to highlight words in a string containing HTML we found we soon ran into problems when the word we were searching for appeared in the middle of a tag..
Imagine the example:
#v#<a href="geekzilla.aspx">you searched for geek
|
 |
LoginStatus not logging users out?
Paul Hayman (2402 views)
|