Tips and Tricks Articles

Nested Master Page Events not being called

Nested Master Page Events not being called This is the second time I've been caught out by this little feature, so I thought I'd geekzilla it for both reference and to help others. Scenario I'm a big fan of MasterPages and Themes as a design principle for web development, and

Paul Marshall - 2,552 views

Returning the first few items from an Array list or IEnumerable collection

Returning the first few items from an Array list or IEnumerable collection, like T-Sql top() I needed to bind the first 5 items in a List<T> to a repeater. Having recently discovered the .Distinct() extension, I had a look through the other methods attached to my List<T> and foun

Paul Hayman - 3,207 views

Returning a Distinct list of values from an array or IEnumerable cllection

Returning a Distinct list of values from an array or IEnumerable collection I recently had a list of Guids in a string which was returned from a group of checkboxes with identical names. I wanted to itterate through Guids and process each one only once. Basicaly, ignoring duplicates. I

Paul Hayman - 4,672 views

Adding a Strong Name to an existing DLL that you don't have the source to

Adding a Strong Name to an existing DLL that you don't have the source to There are times when you need a DLL to have a strong name; putting it in the GAC for example. With 3rd party DLL's this could be a pain. This is how you do it: From a VS.NET command prompt, enter the following:

Paul Hayman - 70,742 views

Getting the ProviderUserKey for the Current User

Getting the ProviderUserKey for the Current User The following gets the ProviderUserKey for the current user. (Guid)Membership.GetUser().ProviderUserKey

Paul Hayman - 3,737 views

ASP.NET Framework 1.1 Validation not working in IE7?

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.

Paul Hayman - 6,608 views

Need a high resolution timer?

Need a high resolution timer I like to profile my code regularly to see if any changes I make during development affect performance. In .Net 1.1 there is a distinct lack of a high resolution timer object. Here's one you can use:

Lee Keable - 2,357 views

TraceListener creates huge log files

TraceListener creates huge log files If you've used the .Net trace listeners, you'll know that they just keep appending to the file specified in the App.Config file, this can lead to some massive log files! Here's a simple TraceListener that logs to a new file for every day.

Lee Keable - 11,805 views

Missing App.Path

Missing App.Path If you have the need to load resources (XSL stylesheets, images etc etc) at runtime, you may need to know the path of the currently executing code. In VB6 you'd just use good old App.Path, here is the .Net equivalent.  using System.IO;  string&n

Lee Keable - 3,932 views

Referencing ConfigurationManager

Referencing ConfigurationManager When I started working in VS2005, I assumed that accessing your AppSettings would be the same as it was in VS2003. On compiling, the IDE served up the following warning. 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method

Barrington Haynes - 5,626 views

SQL Server 2005 mdf file Query String

SQL Server 2005 mdf file Query String To add a SQL Server 2005 local database to one of your projects, create the connection as follows. conn = new SqlConnection(@"server=(local)\SQLExpress; AttachDbFileName=|DataDirectory|MyDatabase.mdf; Integrated Security=false;

Barrington Haynes - 7,676 views

Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()

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: <a href="~/Customers/Profile.aspx" Runat=

Paul Hayman - 40,320 views