Tuesday, September 22, 2009

Video: Road to Redmond (Dutch)

A while ago I got to know Dandy Weyn and Bart De Smet through Facebook. These two people have something in common, which gave me an idea. They both work for Microsoft in Redmond and were born in Belgium.

I thought doing a double-interview might give me some great content for my blog. I contacted them and told them about my idea. They both embraced the idea and took it to another level. They took the time to make a video and show what's life like up there.

The video turned out to be really funny. While talking about what it takes to travel the road to Redmond, they go off-topic a lot, which leads to some good lolz.

Enjoy!




Dandy and Bart, thanks a lot for doing this!

Don't forget to visit Bart's blog.

Saturday, September 12, 2009

Why the javascript beforeunload event is incomplete

The onbeforeunload event fires when a page is being unloaded.

In the intranet webapplications world customers pretty often ask to show a warning when a user leaves a page (by closing the browser, closing a tab, clicking a link,..). This feature is specifically very interesting for data-input-driven webforms where one wrong click can make ten minutes of work undone.

Last week I had to implement this feature in a huge webform which is causing lots of postbacks (firing the onbeforeunload event). Actually I only had to warn the user when they closed the browser or clicked a link in the masterpage. I figured out that the beforeunload event must have some convenient properties, but as you can see below, it had no properties which I could use.



Offcourse there are workarounds for this problem, like there are workarounds for almost all technology problems. But these workarounds often make tasks harder and less "clean".

In my opinion the browsers could and should do something about this. Adding a few properties like unloadedbysrc, unloadedbytag, unloadedbyid would make our life a tad easier.

What do you think?

Wednesday, September 9, 2009

Debugging "SubReport could not be shown."

I've been upgrading a local report which contains multiple subreports, and yes I got that "SubReport could not be shown." error more than once.

Debugging this error is a pain in the a.. All you get is "SubReport could not be shown.", making me want to punch my screen and scream "BUT WHY?"

Just before breaking my screen and going on full tilt, I decided to take a step back and run through my checklist.

Here it goes..

Can the reportviewer find the subreports?

If the subreports are in another location (other folder, other assembly..), the reportviewer will not find them.

The solution for this problem is using the LoadReportDefinition method and passing the report definition as a stream. An example can be found in this post.

Are you passing all parameters?

Doublecheck your report parameters.

Are you passing all the required/correct data to the report?

Are you handling the SubReportProcessing event, to pass the data to the subreports, not the main report?

Did the database definition change? Did a query break? Is the structure of the query still the same as defined in your report definition?

Are there other things to add to this list?

Tuesday, September 8, 2009

Three common mistakes you should avoid when starting with Web Page Resources in ASP.NET

This is a list of of three common mistakes made by developers who start using Web Page Resources in ASP.NET.

1. Not using the right format for the name of a local resources file

The format of the name of a local resources file should be: PageName.PageExtension.resx.

If you don't add the page extension (Aspx, Ascx), you will get the Exception "The resource object with key 'PageTitle' was not found.".

2. Not adding an App_LocalResources folder to each subfolder

Each subfolder must have it's own App_LocalResources folder, else ASP.NET will not be able the find the resource, leading to the "The resource object with key 'PageTitle' was not found." Exception again.

3. Not understanding the difference between GlobalResources and LocalResources

In general global resources should be used when you need a resourcekey in multiple pages through your site. Local resources are page-specific.

This article on MSDN contains a great summary.

You can use any combination of global and local resource files in the Web application. Generally, you add resources to a global resource file when you want to share the resources between pages. Resources in global resource files are also strongly typed for when you want to access the files programmatically.

However, global resource files can become large, if you store all localized resources in them. Global resource files can also be more difficult to manage, if more than one developer is working on different pages but in a single resource file.

Local resource files make it easier to manage resources for a single ASP.NET Web page. But you cannot share resources between pages. Additionally, you might create lots of local resource files, if you have many pages that must be localized into many languages. If sites are large with many folders and languages, local resources can quickly expand the number of assemblies in the application domain.

When you make a change to a default resource file, either local or global, ASP.NET recompiles the resources and restarts the ASP.NET application. This can affect the overall performance of your site. If you add satellite resource files, it does not cause a recompilation of resources, but the ASP.NET application will restart.

Monday, September 7, 2009

Web Page Resources in ASP.NET: CheatSheet

The four most used functions/expressions when working with Web Page Resources in ASP.NET.



More on Web Page Resources in ASP.NET on MSDN.

Tuesday, September 1, 2009

Disable all validation in a Page

In some scenario's you want to disable all the validation in your page.

You could set the CauseValidation property of the buttons causing postbacks.

But what I did was loop through all the Page Validators and disable them.

Here is a codesnippet.



A small tip, but hope it helps.