Thursday, May 28, 2009

Programmatically/Dynamically building an RDLC

I was designing a Local Report when I stumbled upon a shortcoming of the Report Rendering Engine. A Rectangle has a Hidden property. When you set the Hidden property to True, the content of the Rectangle doesn't render, but the space of the content is preserved. In my case, this caused some white pages. So I looked for a way to build a RDLC programmatically. An RDLC is just an XML, so how hard could it be :).

I first searched for an example on MSDN, but I didn't like the way described there. In this article on MSDN they use a XmlTextWriter, which makes the code hard to read and not very maintainable in my opinion. You can find that MSDN article here.

After some further investigation I found the RDLC XSD on MSDN. You can find the XSD here.

I used the xsd.exe Tool to generate a Class based on the XSD. This way you can create an RDLC in a more Object Oriented way, which leads to more maintanable code.

It would be awesome if someone had the courage to add comments, so Intellisense would be able to help creating RDLCs programmatically.

After adding the Report.cs to your solution, you can start making your own RDLCs programmatically. Note that the ReportViewer needs a Stream to read the RDLC.

I chose not to show my whole implementation of my own ReportGenerator, because it's not really a good example. These steps might get you started though.

1. Create a new Report object.
2. Do whatever you want with the object.. Add textboxes, rectangles..
3. Before reading the Report object into the ReportViewer you need to serialize the object to a Stream. I chose to use a MemoryStream. (Don't forget to set the position of the Stream to 0!)

4. Load the Local Report in the ReportViewer using the LoadReportDefinition method.

And that should be it!

Thursday, May 21, 2009

Visual Studio 2010: A few tips for developers

As you all probably know Visual Studio 2010 Beta is available for the public!

You can download it here. An installation walkthrough can be found here.

In this post you will find a few tips. Enhancements have been made to the Editor to make life easier for developers. A few examples can be found below.

Enhanced Docking Behavior

You can do with the windows whatever you want. You can drag them to wherever you want. This is a big improvement. Imagine having your markup open on your left monitor and the code-behind open on your right monitor. Changes that are made in either one of them are immediately adjusted in the other one.


You can zoom into your code by using CTRL + MouseWheel. This will definitely be convenient when editing some config files.

Call Hierarchy

This feature enables you to navigate through your code by displaying all calls to and from a selected method, property, or constructor. This helps you understand how code flows and to evaluate the effects of changes to code.

And the best thing is that Call Hierarchy is available at Design time!

Highlighting references

For example.. When you click on a variable, all the instances of this variable will be highlighted. Take a closer look at the screenshot!

Intellisense Consume-First Mode

This new Intellisense Mode can be used when you are typing classes and members which aren't defined yet.

That's all for now. This is only the top of the iceberg. Looks like we will be spending the next years in a pleasant development environment!

If you want to know more about Visual Studio 2010 and want to keep up-to-date, you can follow these blogs:
- Jason Zander
- Beth Massi

How was your first experience?

Wednesday, May 13, 2009

IE8: Always use the IE7 Standards

Now IE8 is released, you might see your oh-so-beautiful design go crazy. But don't panic, there is a solution.

Microsoft did a good job at making IE8 compatible with older standards.

If you include this meta tag in the head section of your page, IE8 will always try to render the page using the IE7 Standards.

You can check the Document Mode using the IE Developer Tools.

More documentation can be found on MSDN.

Tuesday, May 12, 2009

The report definition for report 'path' has not been specified

The full errormessage is:
The report definition for report 'path' has not been specified. Could not find file 'path'.

If you use an installer to install your webapplication, this error might occur when you try to run a local report (rdlc).

The solution is to set the property "Build Action" of the rdlc to "Content". Now your installer will copy the physical rdlc.

Thanks to my colleague Kris S.

Monday, May 11, 2009

Checking the type of an element using javascript

*Watch out, this is oldskool javascript ;)*

Here is the situation..

We have multiple dropdownlists, and with each dropdownlist belongs another type of element (ex. a textbox, a dropdownlist, ...). For each element, we need another piece of code. So I wrote one small function which can be used for all these dropdownlists.

Here is the function.

A little explanation..

This function has 3 parameters: The dropdownlist to check the selected value of, the control to toggle, and the value to check.

When the value of dropdownlist to check equals the value to check, I show the control to toggle. Else I check what type the element to toggle is, so I can execute the corresponding code.

I hope this saves someone a few minutes :)

Saturday, May 9, 2009

Some more tools

I wrote a small blogpost on some tools I use a while ago. You can find that one here.

In the meanwhile I got to know some more tools..

CodeRush Xpress 9.1 Beta
This is a plug-in for Visual Studio which provides:
- 59 Refactorings
- Powerful navigation tools
- ...

Anyways, this list doesn't tell you much. You can watch the introduction movie.

And the best thing it's free because it's a beta. Get it ASAP!

This is free image and photo editing software completely written in .NET. It's a lot better then the standard paint. It's more like Photoshop but with less features, but for the most people the features in Paint.NET are more than enough! Download it here.

HttpWatch and Fiddler
While we were struggling with some performance issues with an ASP.NET webapplication, we needed to do some HTTP monitoring.

I tried HttpWatch first. This software integrates perfectly with your browser and has a very smooth UI. You can find it here.

Another tool for HTTP monitoring is Fiddler. I haven't tried it yet, but this tool is free. Check out Fiddler.