Wednesday, November 25, 2009

C# ?? Operator

The null-coalescing operator is a great way to save space in your code.

// if ObjectThatCouldBeNull is null then print out the default text
// otherwise print the object value

if(ObjectThatCouldBeNull != null)
{
 Console.WriteLine("{0}", ObjectThatCouldBeNull);
}
else
{
 Console.WriteLine("Value is null");
}

// a better way
Console.WriteLine("{0}", ObjectThatCouldBeNull != null ? ObjectThatCouldBeNull : "Value is null");

// a even better way
Console.WriteLine("{0}", ObjectThatCouldBeNull ?? "Value is null");


sweet :-)
Share:

Wednesday, June 10, 2009

JQuery with maphighlight in IE8

If you have problem using jQuery and maphighlight in Internet Explorer 8, this link explains why:

https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=333905&wa=wsignin1.0

The reason is that IE8 have changed it’s support for VML rendering.

A simple solution to get your page to function in IE8 is to use the following tag

<meta http-equiv="X-UA-Compatible" content="IE=7" />


This will cause the IE capability mode to kick in and everything should now work fine
Share:

Thursday, March 12, 2009

Installing MVC on IIS 6

I needed to get a MVC application installed on a Windows 2003 Server.The following pages helped a lot:

http://www.asp.net/learn/mvc/tutorial-08-cs.aspx

http://blog.codeville.net/2008/07/04/options-for-deploying-aspnet-mvc-to-iis-6/

But still after using the solutions mentioned in these pages the solution would not run. That’s when i realized that asp.net was disabled on the server.

Running the command
aspnet_regiis.exe -i –enable
fixed the problem.. Sometimes you just miss the obvious. :-)
Share: