November 2004 - Posts

Tweaking and Changing Things like the Kernel
30 November 04 12:57 PM | despos | 5 comment(s)

The Scobleizer posted and commented this: Linux lover says he "tweaks and changes" things. What amazes me is just the different perspective on "changing things" in the kernel. Robert wonders if they really do that (i.e., changing and tweaking things). I'd even go further and wonder if they really know what it means outside the single box. "No application is an island" Don Box said at PDC 2003. As long as your machine is an island, tweak and change those things... 

Tools
30 November 04 10:27 AM | despos | 6 comment(s)

I was looking for a great tool for icons and tiny images. I've found IconLover from Aha-Soft and I'm just loving it.

I was wondering if you know some tools out there to seriously help with CHM files. I mean using data-bound templates and styling at least. Not just tools to extract comments out of source files and compile.

 

DHTML Behaviors and THEAD-TBODY-TFOOT Tags
30 November 04 09:49 AM | despos | 8 comment(s)

In the January 2004 issue of MSDN Magazine, I demonstrated how to create a DataGrid control with draggable columns and client-side sorting. In doing so, I modified a free DHTML behavior that Dave Massy wrote as the companion code of an old DHTML Dude column for MSDN online.

According to the MSDN Magazine rating system, that article got rave reviews and received excellent feedback. About 12 months later, I can say that readers raised a couple of major issues about the code:

  • 1) The DHTML behavior deployed as a separate (and scattered) HTC file
  • 2) The necessity of modifying the DataGrid control to make it output extra table tags like THEAD, TBODY, TFOOT.

In the end, using my closing sentences,

A symbiotic relationship between the DataGrid and DHTML can be attained and has lots of advantages for users. But as you can see, it takes a bit of work to coerce the DataGrid into doing everything you want it to do. 

Following up to that, a few days ago I took a reader's suggestion about building a DataGrid that allows to move rows up and down on the client and post changes to the server. Once again, I've found a free DHTML behavior to adapt. This time, it is rowover.htc and belongs to the MSDN DHTML Behavior Library. As mentioned, the results will appear in the March 2005 issue of MSDN Magazine.

How did I work around the two aforementioned issues? Let's start with #2.

In ASP.NET 1.1, the Table control only outputs the <table> tag. Similarly, TableRow only manages <tr> tags. If you install a post 1.1 patch for accessibility, TableCell can sometimes morph into <th>. That's all, though. It doesn’t mean you can’t build a fully qualified table, however. You can always make a control output plain text like Write("<thead>").

In ASP.NET 2.0, the Table and related controls have been fixed. So the TableRow class has a property TableSection that indicates where the row belongs to, be it TBODY, THEAD or TFOOT. And the markup is generated accordingly.

row.TableSection = TableRowSection.TableHeader;

As far as Beta 1 is concerned, though, this doesn’t work automatically for grid controls like DataGrid and GridView. The good news is that unlike ASP.NET 1.1 you now have a more effective workaround to apply. In ASP.NET 1.1, the only reliable trick I've been able to find (and readers' post-article suggestions didn't help much) is to output the grid's content to a string and parse to insert missing tags. By moving this code to an output filter, you can perhaps apply changes to all grids automatically, but I don't see significant performance advantages. Some readers suggested to override RenderBeginTag or similar methods. Believe me, no way. The DataGrid delegates to the inner child table control any rendering tasks. And the Table control doesn't support extra tags. Either you replace the whole rendering engine of the DataGrid (challenging, but really worthwhile?) or you do it the way I did.

What's new in ASP.NET 2.0? Because the new TableRow control has a TableSection property you can now successfully override the CreateRow method on a GridView and the CreateItem method on a old-fashioned DataGrid control.

protected override GridViewRow CreateRow(
   int rowIndex,
   int dataSourceIndex,
   DataControlRowType rowType,
   DataControlRowState rowState)
{
   GridViewRow row;
   row = new GridViewRow(rowIndex, dataSourceIndex, rowType, rowState);

   switch (rowType) {
      case DataControlRowType.Header:
          row.TableSection = TableRowSection.TableHeader;
          return row;
        :
   }
}
Neat and elegant, isn't it?

What about #1? To avoid sparse files like HTC files, in ASP.NET 1.1 you can write a custom HTTP handler that retrieves and downloads the resource setting the proper MIME type. Using a HTTP handler requires you to enter a new line to the web.config file and likely a new entry to the IIS metabase if you decide to use a custom extension (not strictly required).

In ASP.NET 2.0, a new system HTTP handler (named WebResource.axd)  and the [WebResource] attribute let you retrieve resources from assemblies. WebResource is an assembly-level attribute through which you to mark embedded resources as URL-accessible. You first add the HTC file to the project as an embedded resource and then insert the following code to the AssemblyInfo file of the project:


[assembly: WebResource("Mover.htc", "text/javascript")]

To programmatically access the resource (i.e., to compile the Style property of the control to bind the behavior) you use a new method on the Page class—the GetWebResourceUrl method.

I'll probably cover WebResource in a future post; in the mean time, you can take a look at what one of its authors has to say about it. Handing over to Nikhil. And once again.

Semiserious Evolution of the B2B Acronym
30 November 04 09:13 AM | despos | 1 comment(s)

B2B once was used to mean Business-to-Business or so Next, after the Internet bubble implosion, some cynical spirits suggested to change it to Back-to-Bombay. What is it now? Perhaps Back-to-Business or, even better, Bring-to-Bombay?

For me, it today just means Back-to-Blog...

 

Beginning step 2 on ASP.NET 2.0
09 November 04 10:04 PM | despos | 3 comment(s)

I can't certainly say today that I know most of the things that must be known about ASP.NET 2.0. Sure I have a book out there that claims to introduce you to the new platform (and it actually does it...) and I also have written quite a few articles on various aspects of the platform, and am speaking at conferences and delivering some classes, and so on...

However, the more I interact with the new platform the more I feel I have to contrast one of the slogans of ASP.NET 2.0--Cut out coding by an amazing 70%.

That's true for some scenarios--probably the best cases. At school, however, they taught me to always consider the worst case first, and often mostly that. So what about ASP.NET 2.0?

Point #1. We'll keep on writing code for the foreseeable future. We'll just change the outer envelope of the code. No more inline code embedded in pages; much less code in code-behind classes; perhaps slimmer custom controls. I'm led to think that we'll write much more components: ad hoc, strongly focused controls and classes with a fixed, well-known set of interfaces. All in all, it won't probably be that amazing 70%. In any case, a quantum leap forward. In the right direction.

Point #2. The provider model will impact applications much more than many seem to think today. To take advantage of new controls (and related features) and to suck most of the flexibility of the provider model, you may need to rearchitect your apps. I'm not at all sure you'll end up throwing code away; you'll write code for this though. 

Point #3. Localization is much much easier and really requires much less code. Also applications that make heavy use of resources get simplified in 2.0. Resource management is just great. The possibility of FINALLY writing a control that carries all required images and doesn't required scattered files here and there is enough to make (and keep) me just HAPPY.

 

Any customers asking for double encryption?
09 November 04 09:41 PM | despos | 10 comment(s)

A client recently requested to encrypt some critical data twice. I'm not really sure if a double encryption really weakens the strength of the encryption algorithm--a colleague mentioned some weird (to me) laws from the theory of groups (algebra) to apply in this scenario and affect the power of the algorithm. I'm convinced now that to be on the safe side (maybe algebra, surely the mess of managing two keys) it's much better if they simply use ONE key of a doubled size. However, my question is--have you had to face the same request in the past? Any forecasts for the near future?

More Posts