Posts for October, 2004

Passing Type as a parameter

Here’s a useful bit of C# code for creating a method that takes a Type as a parameter from the microsoft.public.dotnet.languages.csharp group. Calling code: MyComponent component;object myobject;MyMethod(myobject, typeof(MyComponent)); Method: public static void MyMethod(object myobject, Type type) { if(myobject.GetType() == type) { // do something }} Useful references: MSDN typeof documentation MSDN using typeof reference
Published in .NET on Wednesday, October 27th, 2004

Jumping to anchors in table cells

Interesting IE observation: You can’t jump to anchors in otherwise empty table cells. This works: <tr>     <td>&nbsp;<a name="myanchor"></a></td> </tr> This doesn’t: <tr>     <td><a name="myanchor"></a></td> </tr> I know I’m doing terrible things to my markup to even want to put an anchor in an empty table cell.. :) Other people seem to […]
Published in Browser quirks on Tuesday, October 26th, 2004

DOM-created radio buttons don't work in IE6

*sigh* This is a nasty little known problem with IE when creating radio buttons using document.createElement(). IE actually creates the buttons, but they can’t actually be selected by the user. The problem is that aparently IE doesn’t let you set the name attributes of elements after they’ve been created. If you update the name attribute, […]
Published in Browser quirks on Saturday, October 23rd, 2004

PNG Alpha transparency code in IE

Because of incompatibilities between IE and the world, to get PNG transparency to work in IE you need to add this to your stylesheet: img.transparent { filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='myimage.png',sizingMethod='scale');} There’s more information at A List Apart and WebFX
Published in CSS on Tuesday, October 19th, 2004

NUnit problem – assembly has no TestFixtures

I’ve been investigating doing unit testing in ASP.NET using NUnit. It’s a very interesting idea, particularly the idea about Test Driven Development, but I’ll post a bit more about that later. NUnit is a really nice piece of software, but I run into a problem when I tried running my first unit test. The error […]
Published in ASP.NET on Tuesday, October 19th, 2004

Regular expressions in C#

Learnt something new today from Merak on the UK Microsoft web developer’s list. One of my early problems when writing regular expressions in C# was that I didn’t realise that is actually an escape character when used in a string in C#. So when I wanted to write an expression like this: /d/ (which means […]
Published in ASP.NET on Tuesday, October 19th, 2004

StackOverflowException and properties

An easy way to get this exception is by refering a property to itself: public string myproperty {     set { myproperty = value; } } The exception looks like this: [StackOverflowException: Exception of type System.StackOverflowException was thrown.] Granted it’s a pretty dumb thing to do.. :)
Published in ASP.NET on Monday, October 18th, 2004

The problems with playing the system

I’ve been thinking a fair bit about search engine optimisation lately since I started looking at url rewriting for one of our customers at work. Before I start my rant I’d like to say I’m not talking about the type of search engine optimisation that makes the quality content of your site more meaningful for […]
Published in Web development on Saturday, October 9th, 2004

Installing ASP.NET in IIS for XP Pro

Installed IIS to do some performance profiling on the site I’ve been developing. Took me a bit of searching to figure out how to enabled ASP.NET on IIS for XP Pro. You just need to run a little program that comes with the .NET framework: C:/WINDOWS/Microsoft.NET/Framework/ -i Useful links: Microsoft aspnet_regiis documentation
Published in ASP.NET on Friday, October 8th, 2004

Things I'd like to have in ASP.NET

A “form element” interface so I could find out things like values from any type of form element without having to write code that’ll handle different types of form elements.
Published in ASP.NET on Thursday, October 7th, 2004

Accessing current style attributes

Had a problem this morning trying to access the display property of html form elements that were hidden because one of their parent elements had the style.display property set to “none”. <tr style="display:none"> <td><input name="foo"/></td></tr> My script worked fine when I called document.getElementById("moo").style.display on the elements whose display property I had set to “none”, but […]
Published in Javascript on Thursday, October 7th, 2004