Nested Master Page Events not being called
Paul Marshall (1333 views)
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 often you
|
Returning the first few items from an Array list or IEnumerable collection
Paul Hayman (1787 views)
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 found .Take(int)
|
Returning a Distinct list of values from an array or IEnumerable cllection
Paul Hayman (2041 views)
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 didn'
|
Adding a Strong Name to an existing DLL that you don't have the source to
Paul Hayman (8377 views)
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:
'
|
Getting the ProviderUserKey for the Current User
Paul Hayman (2239 views)
Getting the ProviderUserKey for the Current User
The following gets the ProviderUserKey for the current user.
#c#(Guid)Membership.GetUser().ProviderUserKey
|
ASP.NET Framework 1.1 Validation not working in IE7?
Paul Hayman (4735 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
|
Need a high resolution timer?
Lee Keable (1624 views)
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:
#c#using System;
#c#using System.Diagnostics;
#c#using Syst
|
TraceListener creates huge log files
Lee Keable (4146 views)
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.
#c#using Syst
|
Missing App.Path
Lee Keable (3094 views)
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.
#c# using System.IO;
#c#
#c# string Location = Path.Ge
|
Referencing ConfigurationManager
Barrington Haynes (4198 views)
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 is ob
|
SQL Server 2005 mdf file Query String
Barrington Haynes (5688 views)
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.
#c#conn = new SqlConnection(@"server=(local)\SQLExpress; AttachDbFileName=|DataDirectory|MyDatabase.mdf; Integrated Security=false; User Instance=false");
|
Programmatically resolving ~ URL's to the Virtual Root using ResolveURL()
Paul Hayman (15617 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
|