Tuesday, January 24, 2006

Visual Studio 2005 Missing Windows

As I was debugging with Visual Studio 2005 I wanted to display the Immediate window (old habits die hard). When I looked for it in as a Debug|Windows menu item it was not there. I searched around menu items some and could not find it.

Instead I used CTL+ALT+I to access (display) it.

The same issue occurred when I wanted to access (display) the Exceptions window. I had to use CTL+ALT+E to access (display) it.

I wonder if this was by Visual Studio 2005 design or not; in any case these 2 windows are available....

Monday, January 23, 2006

ASP.NET 2.0 Changing SiteMap files

I have been testing out navgation in ASP.NET 2.0, especially the sitemap feature.

I wanted to dynamically change sitemaps and found that it can be done as follows:

First define a few different sitemap files (i.e. x.sitemap, y.sitemap) within your project (i.e. Company1SiteMap, Company2SiteMap).

Then in the web.config file add the following entries:

<siteMap defaultProvider="Company1SiteMap" enabled="true">
<providers>
<add
name="Company1SiteMap"
type="System.Web.XmlSiteMapProvider"
siteMapFile="~/x.sitemap" />

<add
name="Company2SiteMap"
type="System.Web.XmlSiteMapProvider"
siteMapFile="~/y.sitemap" />
</providers>
</siteMap>


If a siteMapPath control is used on a form without specifing a siteMapProvider then the default provider is used which by default is a project file named web.sitemap. The default is changed (in this case to x.sitemap) by the web.confg entry:

<siteMap defaultProvider="Company1SiteMap" enabled="true">

The sitemap file defined by the Company1SiteMap <providers> entry is now the default sitemap for the project.

To define other sitemaps for the project, add entries in the <providers> section as shown in the above web.config entries.

To dynamically change the sitemap used by a sitemappath control just set the SiteMapProvider propery of the control with the name of the entry that points to the .sitemap file that is desired:

(Assume a sitemap control on the form named SiteMapPath1)Me.SiteMapPath1.SiteMapProvider = "Company2SiteMap" 'will use y.sitemap

Now, the SiteMapPath1 sitemappath control will use the sitemap file defined by the entry named Company2SiteMap (y.sitemap)

I tested this by changing the sitemap from the default (x.sitemap) to y.sitemap in a button click event and it worked like a champ.

Tuesday, January 17, 2006

ASP.NET 2.0 and Crystal Reports

After a long rest I am back blogging.

Recently I have been spending a lot of time with Visual Studio 2005 exploring both ASP.NET and traditional Windows Forms projects.

I have a client in a medium sized company that has struggled with report distribution off and on for sometime. Having a small IT staff they wanted easy desktop installation along with “pretty” report printing capability from the client.

We discussed using Visual Studio 2003 and Crystal Reports with the Crystal Report Viewer control. Actually, a while back I did a small prototype and had many issues; finally we gave up and moved on to other projects.

Enter Visual Studio 2005. I decided to give it a try. In less than one hour I had a simple Crystal Report being displayed on a ASP.NET 2.0 web form. First, I populated a dataset with data for the report using ADO.NET (nothing special here). I created a rather simple Crystal Report using the Crystal Report wizard. Next, I bound the Crystal report to the dataset. Finally, I used the Crystal Report viewer control on a Web form to show the Crystal Report in the browser and provide formatted printing capability. It worked with no difficulty.

The two cool things about the process were using a 1) dataset as a data source for the crystal report (as opposed to having crystal do the data population) and 2) Adobe Reader is used to display the report when the client decides to print it at the browser; this lets a client choose the printer they want to use for printing (along with all the other printing goodies) and prints a formatted report (i.e. real page breaks etc) or for that matter export to a different format (word, pdf, excel). Since most desktop’s these days have Adobe Reader this technique for printing works like a champ. The biggest item however was that I had no problems doing this on an ASP.NET 2.0 page whatsoever; everything worked as advertised.

This is one possible solution for providing well formatted printed reports from a browser.

The client loved it and has begun to deploy various reports using this approach.