-
-
In my ASP.NET 2.0 Core Reference book, much of the information on pages 133-135 appears to be incorrect.
In particular, speaking of the HtmlHead control I talk about a Metadata member that is no longer there. To add a new meta tag, you have to create a new HtmlMeta control and add it to the Controls collection of the HtmlHead control. This technique is described in the book as an alternate technique whereas it is in the final version of ASP.NET 2.0 the only viable route.
At a closer inspection, I would say that the team completely changed the implementation of the HtmlHead control, as it does not implement the IPageHeader interface that is also mentioned in the book. Now HtmlHead inherits HtmlGenericControl and exposes a Stylesheet and Title property. Here's the Visual Basic .NET code you need to add a meta tag programmatically:
Private Sub AddPageExitMetaTag()
Dim meta As New HtmlMeta
meta.HttpEquiv = "Page-Exit"
meta.Content = "progid:DXImageTransform.Microsoft.Fade(duration=.4)"
If Not Me.Header Is Nothing Then
Me.Header.Controls.Add(meta)
End If
End Sub
To remove existing meta tags, you should locate them in the Controls collection and remove using the Remove method on the ControlCollection class.
PS: Credits go to Sam for pointing this out.
-
-
This should not be something new to great ASP.NET devs; however, just in case :)
ObjectDataSource is designed to work with classes in the business layer of the application. An instance of the business class is created (via reflection) for each and every operation performed and destroyed shortly after the operation is complete.
In case of business objects particularly expensive to initialize, you can resort to static methods or you can implement a custom caching or pooling mechanism.
Instances of the business object are not automatically cached or pooled. Both options, though, can be manually implemented by properly handling the ObjectCreating and ObjectDisposing events on an ObjectDataSource control. The ObjectCreating event fires when the data source control needs to get an instance of the business class. You can write the handler to retrieve an existing instance of the class and return that to the data source control.
public void OnObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
BusinessObject bo = RetrieveBusinessObjectFromPool();
if (bo == null)
bo = new BusinessObject();
e.ObjectInstance = bo;
}
Likewise, in ObjectDisposing you store the instance again and cancel the disposing operation being executed.
public void OnObjectDisposing(object sender, ObjectDataSourceDisposingEventArgs e)
{
ReturnBusinessObjectToPool(e.ObjectInstance);
e.Cancel = true;
}
From the ObjectDataSource perspective, it makes no difference. Given the internal implementation, you perhaps save a few IL operations if you have static methods. However, having static methods on the BLL/DAL may pose issues at another level.
What if you test a business class that calls the DAL internally and the DAL fails. Can you figure out what really happened? Does the business class work or not? To effectively test a business layer that calls into a DAL you need to focus on the object under test. Mock objects come to the rescue. Mock objects are programmable, polymorphic objects that present themselves as others and can wrap DAL anomalies and signal them out clearly making the test succeed if nothing else happens. The point is that some mocking toolkits typically don’t like static methods and don't offer proper support.
-
-
Scott was nice enough to point you to my 100th MSDNMag column. The column shows how to extend the GridView control to make it support multiple selection with additional client side support like the Hotmail grid. Basically, I create and persist a checkbox column on the fly and add some script code to change colors when users check and uncheck items. In the upcoming June 06 column, I create a custom ASP.NET provider-based service to override the existing tracing subsystem and create a custom component to parse and change at will the trace output. You can select which sections to include and add new ones. You can collapse/expand the blocks and save data to a persistent medium. And more. Don't miss it--
-
-
A new post about the Atlas book. It won't be an "advanced" book; its main purpose is sharing the big picture of Atlas and why it is a key technology--not just a cool one. There will be a lot of code, of course, and insights on the internals. Essential features such as controls, binding, behaviors, client-side framework will be surely discussed but it will be designed to be "Introduction to the Atlas Framework" or something along these guidelines.
We're also studying ways to keep it up to date at least until Beta 1 of Atlas (a ? number of months from now). Plans exist to follow up with a Core Reference book by the time Atlas ships.
More on this blog as I get more information myself :)
-
-
It's been a while since last post and even more since last code-oriented post. Playing tennis 3 times a week and writing articles and code is a challenge. And proves hard, especially if you also have to travel around. BTW, next stop is tomorrow morning--DevConnections Europe in Nice. Given the weather we're having in Rome, it's gonna be very nice in Nice this spring :)
Next big project? An intro book on Atlas (details on contents to come as soon as I get to know them <g>). Ship date? Only a few (read, few) months