Browser toolbars for web development

I’ve been doing a lot of HTML and CSS recently, and checking that pages appear and behave the same in different browsers can be a bit of a pain. Fortunatley, there are several toolbars that can be used to make this process easier.

Internet Explorer

  • Developer Toolbar
    This is a toolbar for Internet Explorer versions 6 and 7 that adds a DOM and CSS explorer and editor, as well as tools for viewing pages structures and various type of validation.

  • Web Development Helper
    This is similar to the Developer Toolbar above, but geared more for ASP.Net. It features several browsers for view state, caches, header and response details and call stacks, as well as a DOM explorer.

Firefox

  • Firebug (also here)
    This is an extension that adds a CSS, HTML, Javascript and DOM monitor and editor to the browser, as well as a request monitor and a element inspector.

  • Web Developer Toolbar (also here)
    This is a toolbar that adds lots of utilities and tools, including validation and page information and outlining.

  • HTML Validator (also here)
    This is an extension that adds an HTML validator to the browser that validates pages in real time and displays warnings and errors in the page status bar.

  • Dust-Me Selectors
    This is an extension that enables you to inspect CSS style sheets for selectors and styles that are loaded but not used when browsing pages. Useful for consolidating style sheets after a site redesign. NOTE: this didn’t install properly using the xpi file, but worked following a manual install.

  • Modify Headers (also here)
    This is an extension that enables the viewing and modification of HTTP headers.

  • User Agent Switcher (also here)
    This is an extension that allows the configuration of custom user-agent strings and enables switching them whilst browsing.

  • IE Tab (also here)
    This is an extension that allows the viewing of pages using the Internet Explorer rendering engine, but within the Firefox application.

  • IE View
    This extension is similar to the IE Tab extension above, but will open Internet Explorer as a separate window instead of embedding it inside FireFox.

  • IE View Lite (also here)
    This extension is a rewrite of the IE View extension above, but written to be more compact and lightweight.

  • Opera View (also here)
    This extension is similar to the IE View extension above, but will open pages in Opera instead of Internet Explorer.

Opera

  • Web Development Toolbar & Menu
    This toolbar and menu set add a set of menus and a toolbar. The menus contain quick links directlry to HTML, CSS, DOM, JS and Unicode reference information. The toolbar adds tools for inspecting page contents, validation, page source viewers and form manipulation.

  • Opera Developer Console
    This tool adds a button onto a toolbar that when clicked opens a windows containing a DOM, JS, CSS and HTTP browser for the current page.


Fixing database logins after a restore

For several years now I’ve been moving development databases between SQL Servers using backup and restore. When you restore the database on the target server, the logins for the database are invariably broken with the database user having an empty login name, meaning that they cannot log in to the database. My usual fix is to delete the database user and re-add it. Paul Hayman however pointed out a useful stored procedure to fix broken logins:

sp_change_users_login 'Auto_Fix', 'username'

where username is the name of the account to fix.

The Auto_Fix option will attempt to match the broken login with an existing user with the same name.

More information on this can be found in the MSDN documentation. Specific things to note are that it only works with SQL Server and not Windows logins, and that you must be a member of the sysadmin fixed server role for it to work.


Running the OUTPUT clause from C#

SQL Server 2005 introduced a new feature called the output clause. This enables INSERT, UPDATE and DELETE queries to be run, with the original information which has been changed being returned. This is particularly useful if you want to run a query and know what has been changed by it by returning the identites of the modified rows.

The full documentation for the output clause can be found in SQL Server 2005 Books Online.

In trying to use this feature, I could get it to work in a query window, but when trying it using C# and ADO, it was not obvious how to execute the query and return the results because the ExecuteNonQuery() method of SqlCommand only returns the count of the number of rows that have been updated. After a bit of unsuccessful searching, I came across a post by Keyvan Nayyeri with something that gave me an idea:

OUTPUT clause works like a SELECT statement but its usage differs in INSERT, UPDATE and DELETE commands

Switching my code around to run the update query using the ExecuteReader() method of SqlCommand as would be used for a SELECT query proved to be fruitful, enabling the returned result set to be read.


Windows and .Net framework default versions

Aaron Stebner has compiled a list of which version of the .Net Framework is included in which version of Windows by default:

Operating System Framework Version Included As
Windows XP Home/Professional SP1 .NET Framework 1.0 + SP2 MSI Based Installer
Windows XP Home/Professional SP2 .NET Framework 1.1 + SP1 MSI Based Installer
Windows XP Media Center Edition .NET Framework 1.0 + SP2 OS Component
Windows XP Tablet PC Edition .NET Framework 1.0 + SP2 OS Component
Windows Server 2003 (all editions) .NET Framework 1.1 OS Component
Windows Server 2003 R2 .NET Framework 2.0 MSI Based Installer*
Windows Vista (all editions) .NET Framework 2.0 & 3.0 OS Component

* although it appears as an OS component, it is actually just an MSI based installer.

The MSI based installers can be used to install or uninstall the .Net Framework from the OS, enabling it to be removed completely if needed.

Very useful if you are targeting specific platforms with your .Net applications.


AssemblyFileVersion compiler warning

If you are using the AssemblyFileVersion attribute to mark your compiled assemblies with specific Win32 file version numbers, you may get a compiler warning with certain revision numbers. The compiler warning looks like this:

warning CS1607: Assembly generation -- The version '2.0.0.070105' specified for the 'file version' is not in the normal 'major.minor.build.revision' format.

This warning is documented as occurring when the version string is not in the major.minor.build.revision format, but does not explain why it happens for the example above.

Frans Bouma updated his existing post with the reason why. The revision part of the version number must not exceed 65535 (ie. a 16-bit number). If it does, the compiler generates the warning. The MSBuild Team posted about the same thing, but also provided the fact that it is the underlying operating system that imposes this limit.


The difference between format and quick format

Having done several installations of Windows over the years and always chosen the “quick format” option over the normal format option (mainly due to the time it takes to do a full format compared to a quick format), I finally looked into what the differences between the two are. Microsoft’s site has a knowledge base article about this very thing.

A full format will wipe the disk, format it and run a check disk to find any bad sectors. A quick format will wipe the disk and format it, but will skip the check disk stage. As it turns out, the check disk stage is the thing that causes a full format to take a lot longer than a quick format.

If formatting a new hard disk, it is probably wise therefore to do a full format to find any sectors that may have been damaged whilst the disk was in transit. If formatting an old disk, it is already in a known state and so a quick format should suffice.


Accessing network file shares from a command prompt

If you’ve ever tried to access a network file share in a command prompt by simply using the cd command, you’ll know that it just complains that “CMD does not support UNC paths as current directories”. Well, there is a way to do it (two in fact):

net use z: \\machine\share
pushd \\machine\share

Both of these approaches map the network share to a local drive letter that you can change to using the cd command.

The first one can be combined with the /user switch to provide additional user details:

net use z: \\machine\share /user:domain\username

The bonus of using the pushd command over the net use command is that it will automatically change the current directory to the mapped drive (which will be the first unused drive letter available in reverse alphabetical order). Also, when finished with the network share, you can use the popd command to remove the mapped drive.


Google page rank and redirection

After reading Jeff Atwood’s recent post about URL rewriting to prevent duplicate URLs, I started to look at my own site’s redirections, specifically with regards to Google’s page rank. The first thing I noticed was that I had two different page ranks for this site.

http://adrianbanks.co.uk had a page rank of 3, whilst http://www.adrianbanks.co.uk had a page rank of zero, even though I’ve never really used the http://adrianbanks.co.uk version of the url.

Jeff’s ISAPI rewrite rules were helpful, but were not going to work on an Apache server. The Apache docs for the URL rewriting engine were very detailed, but a little too verbose to glean which exact rules I needed. Luckily, the Search Engine Promotion Help site has an example of exactly what I was after.

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.adrianbanks\.co\.uk [NC]
RewriteCond %{HTTP_HOST} !^report\.adrianbanks\.co\.uk [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^(.*) http://www.adrianbanks.co.uk/$1 [L,R=301]

The only alteration I had to make was to add in an extra line to stop any subdomains of my site being redirected to the main site.

Now for a quick explanation of how the rules work:

  • The RewriteRule will only run if all of the preceding rewrite conditions (RewriteCond) are true.
  • Line 1 turns on the rewrite engine in Apache.
  • Line 2 will be true if the host url is not www.adrianbanks.co.uk.
  • Line 3 will be true if the host url is not report.adrianbanks.co.uk (this is my alteration for my subdomain).
  • Line 4 will be true if the host url is not empty.

Only if all of these conditions are met will the rule run.

Having made this change, the page rank for http://www.adrianbanks.co.uk has now jumped to up 3.


Ambiguous match found

Whilst porting an ASP.Net application to the .Net 2.0 framework, I came across a spurious error when viewing a few specific pages. The error was occurring during the runtime compilation of these specific aspx pages.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Ambiguous match found.

To make this error more confusing, the error was reported on line 1 of the aspx page which contained nothing more than the page directive tag.

After a bit of searching, I found the cause of the problem. The cause was that there were two member variables declared with names that differed only by case (one was an ASP.Net PlaceHolder control, the other an int). Simply renaming one of the variables solved the compilation error.

Eran Sandler has also encountered this problem, but delves a lot deeper into what is going on.