# Wednesday, September 13, 2006

I installed the latest bits of the Release Candidate recently and really like it. Another great thing to find out is that javascript seems to be much faster now. This will especially be a great boost since javascript's becoming more and more important with the AJAX whirlwind. Also Microsoft AJAX will greatly benefit from this improvement.

I got the news from Ajaxian, here and here.

Grz, Kris.

Wednesday, September 13, 2006 7:40:38 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 

I'm probably one of the last blogging about this but Atlas, the AJAX framework by Microsft, is going to be renamed. Also other good news: they'll do their best to ship a version 1.0, which will be supported, this year. Now we only get to get used to the new names:

  • Microsoft AJAX Library:  The client-side JavaScript library (i.e., all the .js files) that works with any browser and also supports any server-side framework, not just ASP.NET.
  • ASP.NET 2.0 AJAX Extensions: The server-side functionality that seamlessly integrates with ASP.NET and uses the same programming model familiar to existing ASP.NET developers.
  • ASP.NET AJAX Control Toolkit: The set of free, shared source controls and components that currently form the "Atlas" Control Toolkit community project hosted on CodePlex.
  • Microsoft AJAX = Microsoft AJAX Library + ASP.NET 2.0 AJAX Extensions.

You can read more about it on the blogs of Scott Guthrie, Brian Goldfarb & Keith Smith.

Grz, Kris.

kick it on DotNetKicks.com

Wednesday, September 13, 2006 5:42:43 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, September 09, 2006
# Wednesday, September 06, 2006

Unfortunately I don't understand Portugese. The reason why? There are a bunch of video downloads available right here.

Grz, Kris.

kick it on DotNetKicks.com

Wednesday, September 06, 2006 7:22:08 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, September 04, 2006
Monday, September 04, 2006 8:26:49 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, August 29, 2006

People that use ASP.NET know that it's very easy to use the Properties pane in visual studio to quickly set some properties on a server control. By default already a lot of such properties are made available but sometimes you just want something that just doesn't come out of the box. Luckely the WebControl class also provides the Attributes property which is of type AttributeCollection. You can use the Add method to add new attributes to your control.

To make it more clear I created a small demo page that I used to answer a question on the ASP.NET forums.

    1 <%@ Page Language="C#" %>

    2 

    3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    4 

    5 <script runat="server">

    6 

    7     protected void Page_Load(object sender, EventArgs e)

    8     {

    9         ListBox1.Attributes.Add("ondblclick", "GetValue();");

   10     }

   11 </script>

   12 

   13 <html xmlns="http://www.w3.org/1999/xhtml" >

   14 <head runat="server">

   15     <title>Untitled Page</title>

   16     <script type="text/ecmascript">

   17     function GetValue()

   18     {

   19         box = document.getElementById('ListBox1');

   20         x = box.options[box.selectedIndex].value;

   21 

   22         if(document.all)

   23             document.getElementById('Label1').innerText = x;

   24         else // FireFox doesn't implement the innerText property.

   25             document.getElementById('Label1').textContent = x; 

   26     }

   27     </script>

   28 </head>

   29 <body>

   30     <form id="form1" runat="server">

   31     <div>

   32         <asp:ListBox ID="ListBox1" runat="server">

   33             <asp:ListItem>One</asp:ListItem>

   34             <asp:ListItem>Two</asp:ListItem>

   35             <asp:ListItem>Three</asp:ListItem>

   36         </asp:ListBox></div>

   37         <asp:Label runat="server" ID="Label1" />

   38     </form>

   39 </body>

   40 </html>

On line 9 you can see that I add an attribute. In this case the ondblClick javascript event. This results, once rendered in a browser to have the ability to double click on an item and have the selected value set as being the text of the label control. The javascript function that accomplishes this task is on line 19 - 25.

Tuesday, August 29, 2006 7:21:02 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, August 28, 2006

Just got back from vacation and look what Microsoft provides: Internet Explorer 7 RC1. Get it while it's hot.

Grz, Kris.

IE
Monday, August 28, 2006 6:19:08 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, August 19, 2006

For some projects I like to start with a blank solution and add several projects to it like a class library, web project, ... Since I installed Visual Studio 2005 Team System for Developers a while ago I wanted to go for this approach for a test project. Unfortunately the solution itself dissapeared after adding the first project.

It turned out to be a setting under Tools | Options, Projects and Solutions where you can check the checkbox Always show solution.

Grz, Kris.

Saturday, August 19, 2006 12:32:51 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, August 18, 2006

I've written already some articles in the past about the null coalescing operator (1) but recently my colleague found some "strange" behavior when using this operator. First of all the guilty code:

    1 using System;

    2 using System.Collections.Generic;

    3 using System.Text;

    4 

    5 namespace ConsoleApplicationNullableTypes

    6 {

    7     public class NullCoalescingTestWithinObject

    8     {

    9         static void Main(string[] args)

   10         {

   11             int multiplicator = 5;

   12             int workRegime = 6;

   13 

   14             SomeObject so = new SomeObject();

   15             so.Test = 7;

   16 

   17             decimal result = (so.Test ?? 0 * multiplicator) / workRegime;

   18 

   19             Console.WriteLine(result.ToString("N"));

   20 

   21             Console.ReadLine();

   22         }

   23     }

   24 

   25     internal class SomeObject

   26     {

   27         private decimal? _test;

   28 

   29         public decimal? Test

   30         {

   31             get { return _test; }

   32             set { _test = value; }

   33         }

   34     }

   35 }

 The actual behavior for investigation is on line 17. The parenthesis are omitted around the statement so.Test ?? 0. This causes the following code to be produced (I used Lutz Roeder's .NET Reflector tool for this):

private static void Main(string[] args)
{
      int num2 = 6;
      SomeObject obj1 = new SomeObject();
      obj1.Test = new Nullable<decimal>(new decimal(7));
      Nullable<decimal> nullable1 = obj1.Test;
      Console.WriteLine(((nullable1.HasValue ? nullable1.GetValueOrDefault() : new decimal(0)) / ((decimal) num2)).ToString("N"));
      Console.ReadLine();
}

The output is 1.17 and not really what one would expect.

Now with the parenthesis placed around the statement so.Test ?? 0 so line 17 becomes:

   17 decimal result = ((so.Test ?? 0) * multiplicator) / workRegime;

The output becomes 5.83 and is what is expected. Now the following code is generated:

private static void Main(string[] args)
{
      int num1 = 5;
      int num2 = 6;
      SomeObject obj1 = new SomeObject();
      obj1.Test = new Nullable<decimal>(new decimal(7));
      Nullable<decimal> nullable1 = obj1.Test;
      Console.WriteLine((((nullable1.HasValue ? nullable1.GetValueOrDefault() : new decimal(0)) * ((decimal) num1)) / ((decimal) num2)).ToString("N"));
      Console.ReadLine();
}

For developers whom are still new to this new operator you must be aware of the operator precedence in C#(2). The * operator is normally executed before the ?? operator. But in the generated code we can clearly see that the num1 variable, in our code multiplicator, is omitted which causes some strange side effects to your code to kick in.

Grz, Kris.

(1): Testing upon Nullable types in C# 2.0 and Be sure to put in some default value when testing with Nullable types in .NET 2.0.
(2): operator precedence in C#

kick it on DotNetKicks.com

Friday, August 18, 2006 1:30:17 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, August 17, 2006

Hi,

I'm just testing out Windows Live Writer. A completely new tool by Microsoft, still in Beta but it works already great with dasBlog. You can also extend it with extra plugins (1). It still lacks some extra's but I already like the nice integration with dasBlog. Even the Categories are available.

Update: There are already some nice plugins available on CodePlex: Window Live Writer Plugins, Flickr4Writer and Tag4Writer.
Update 2: It seems another VISUG member also has created a plugin for Live Writer: SyntaxColor4Writer.

Grz, Kris.

(1): windows live writer plugins: flickr and tagging and Write a Windows Live Writer plugin using C#.

kick it on DotNetKicks.com

Thursday, August 17, 2006 6:24:39 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |