October 2004 - Posts

Bug or Missed Feature?
26 October 04 07:35 PM | despos | 1 comment(s)

Scenario: Updating a data source in the context of a ASP.NET 2.0 application

Actors: ASP.NET 2.0, GridView, SqlDataSource

Story: You populate a GridView using the datasource, attach an UPDATE statement to the data source, write NO line of code, and try to update the underlying data source. 

In any pre-Beta1 builds that worked just fine. Apparently, in Beta 1 you have to explicitly display the key column (say, customerid) and make it editable too. Otherwise, you get an error due to a missing @customerid parameter.

As of yesterday I would have called it a bug slipstreamed in the Beta 1 regardless of the controls. As of today, I'm not that sure it is a bug. It could be feature that we all missed because not documented yet. To have the Beta 1 update code work as expected, try changing @customerid (or whatever it is) with @original_customerid (or @original_whatever-it-is).

It works for me. And works for all broken examples in my Introducing ASP.NET 2.0 book.

What about you?

ColorTranslator
26 October 04 11:24 AM | despos | 23 comment(s)

Please raise hand who knows about a .NET class named ColorTranslator. I've been looking for a similar class for too long and now the excellent Lutz Roeder's .NET Reflector revealed that it exists. And it's there since the beginning of the .NET Framework.

ColorTranslator is a fairly simple, sealed class that acts as a utility tool to convert between the various formats of colors: HTML, OLE, Win32, system and so on. It proves useful (at least from my perspective) to control developers especially when one needs to accept a color through a System.Drawing.Color property and then render it back to as a HTML string. This normally happens when you need to set a Style color attribute.  

You can't just use the ToString method on Color. The string you get in this way is a description of the color but nothing that a browser can recognize. You have better luck if you opt for the Name property of the same System.Drawing.Color class. As the property name suggests, though, in this case you get the name of the color which turns out to be a "known" color like Lavender, Purple, Cyan, and so on. What if you express the color through its base R-G-B components? For example, imagine you get a color as follows:

Color c = Color.FromName("#112233");

Next, you need to render the color back to its HTML string: #112233. Try it.

You have to build the string manually. You first check the color against the list of known colors and if it's not there you build the string by prefixing R-G-B components with a # symbol. Just what ColorTranslator does free of charge for you. 

string htmlColor = ColorTranslator.ToHTML(c);

Easy and effective.

 

Beyond Imagination: ASP.NET with Assembly (language)
07 October 04 05:32 PM | despos | 8 comment(s)

Don't know about you, but I often leave my mind free of flying over unexplored areas--sort of personal, occasional sabbatic. It mostly happens during loong trips which can easily be when you're on a car/bus going from north of Rome to the southern part of the city. It results in a sort of dream totally unrelated to the surrouding reality.

Once it happened during one of these "trips". It was about 12 years ago, at the very beginning of my career; I was working for a telecom company on a CICS-COBOL project. It was the exciting time of Borland's turbo magic and OOP was the new verb. OOP everywhere and for everybody.

I dreamt of becoming the guru and inventor of an object-oriented version of the assembly language. Something like this:

var ax = new Cpu.Register(Registers.AX);
ax.Value = 1;

No way it happened. Later, I also dreamt of a unique runtime engine for all Windows applications, with more luck as it turned to .NET only a few years afterwards.

As you can see here, my oldest dream is going to come true. 80386 assembly to build ASP.NET pages. Just cool.

 

PS: As my pal John Robbins (the mythical MSDN Bugslayer) said, his Visual Object Assembler is on the way. John, my god, we shared the same dream for such a long time ...

ASP.NET Vulnerability: Where's Exactly?
07 October 04 10:51 AM | despos | 1 comment(s)

Unless you live disconnected and in a dark cave with no wireless network nearby (ain't you participating to a reality show?) you SHOULD know by now of the serious vulnerability issue (read, security-related bug) that affects ASP.NET. I've counted three different alert messages from MS--looks like they know all of my aliases :-)

Only here, though, I've found a readable and understandable description of what happens and where. Canonicalization sounds weird to me and is not a control or a config section. For a serious call to action, read the short note from Keith Brown. Thanks, Keith!

FW: IIS7
01 October 04 10:27 AM | despos | 2 comment(s)
Found this. Overall, a great news. If facts will confirm it...
More Posts