Category: HowTo

HowTo: Add a body onload script to a page that uses a MasterPage

When you use a MasterPage to define the design of your website, you might come across the problem that there is no body element in a web content form. This can be a problem when you want to add an onload script to a specific page. You could of course add the onload on the …

Read More “HowTo: Add a body onload script to a page that uses a MasterPage”

The absolute minimum every software developer …

One of the posts that is being read quite frequently over here is HOWTO: Encode a password using MD5 in C# (or: howto calculate the MD5 hash for a string). One of the (many) reactions to that post was from one Simucal, stating: Also, to the original poster, Rick van den Bosch… shame on you …

Read More “The absolute minimum every software developer …”

Backing up and restoring Visual Studio settings

When roaming the MSDN forums for unanswered questions for me to answer, I come across a lot of questions about any of the following: Intellisense acting weird Intellisense not showing up at all Menu items that are all garbled up Missing buttons on toolbars Complete toolbars missing Keyboard shortcuts acting weird Keyboard shortcuts not working …

Read More “Backing up and restoring Visual Studio settings”

LinkButton inside UpdatePanel results in full postback, UpdatePanel not triggered

When you dynamically generate a LinkButton in code that will be placed inside an UpdatePanel, you’ll experience that the Click event for the LinkButton results in a full postback in stead of the UpdatePanel being triggered. There’s a rather simpel solution to this problem…First, let’s take a look at the scenario. Consider this HTML:There’s a …

Read More “LinkButton inside UpdatePanel results in full postback, UpdatePanel not triggered”

Getting the ModalPopupExtender to work in SharePoint 2007

Getting the ModalPopupExtender from the Ajax Control Toolkit to work (decently) in SharePoint was not exactly a walk in the park. With a default SharePoint installation, the modal popup is partly positioned ‘outside’ of the page (you only see the bottom right part of the popup in the top left corner of the browser). Postbacks …

Read More “Getting the ModalPopupExtender to work in SharePoint 2007”

I8 converter – Download (sourcecode available)

One of my colleagues pointed out the new Fine-grained password policy feature in Windows Server 2008. As you can see in this post at The Sean Blog, some values have to be entered in the I8 format, which isn’t very user friendly. Because of that, he asked me if I could whip up a tool …

Read More “I8 converter – Download (sourcecode available)”

PageRequestManagerServerErrorException (status code 500)

In a quick AJAX demo I had to create today, I ran into a (somewhat cryptic) PageRequestManagerServerErrorException. I needed a simple form of the Cascading Dropdown, one that doesn’t use a (web)service for its data, but gets it from a simple method. Here’s the setup, and the cause…Lets start with the exact error message:Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred …

Read More “PageRequestManagerServerErrorException (status code 500)”

Hooray (x 2) for MSDN library Community content

There are several steps to creating a custom web service to be hosted in SharePoint. The MSDN library has a walkthrough on creating a custom web service. After having followed this walkthrough thoroughly, I though my web service was good to go. Unfortunately all I saw was an error: “Could not load type ‘ThisAndThat’ from assembly ‘SoAndSo’”. Just as …

Read More “Hooray (x 2) for MSDN library Community content”

HowTo: Set the Theme for a MasterPage (from code)

The MasterPage doesn’t have a property for setting the Theme at design time. Despite this, I wanted to set the Theme for a MasterPage, so I decided to set it from code. I was aware of the possibility to set the Theme through the web.config, but that wasn’t the way I wanted to set it. …

Read More “HowTo: Set the Theme for a MasterPage (from code)”

HowTo: Disable specific Code Analysis rules for a Team Build

Thanks to the MSDN forums (and specifically one Hua Chen), I found a way to disable specific code analysis rules for a team build. In this post I’ll combine the steps I followed earlier with the description given at the MSDN forum. I’ll start out with some steps earlier on in the process: how to quickly get a list …

Read More “HowTo: Disable specific Code Analysis rules for a Team Build”

Disable specific Code Analysis rules for a Team Build

After searching a bit, I found a way to disable specific Code Analysis rules for a team build. Or at least I thought so… The RunCodeAnalysis tag in my build.proj file is set to ‘Always’ to override the individual project settings, and I added the ‘CodeAnalysisRules’ tag to exclude some rules as a test. (See below …

Read More “Disable specific Code Analysis rules for a Team Build”

Unit Test Adapter threw an exception

“Unit Test Adapter threw exception: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information..”This error popped up at one of the testers of our project this morning. The unittests he selected worked fine on my machine, but all failed on his with the above message. After …

Read More “Unit Test Adapter threw an exception”

Defensive programming

We all encountered them in the field somewhere along the way: pieces of code that are based on assumptions. There’s something fundamentally wrong in assuming when writing code. I can understand that, looking at the big picture, you sometimes have to make an assumption when developing software. Some things you just can’t know for sure. This might concern something …

Read More “Defensive programming”

HowTo: determine which object (and method) called another method

Sometimes when you’re inside a method you would like to know which method called it. Or even which object. For instance when you write a TraceListener, it might be pretty cool to make the TraceListener smart enough to find out what object called him and from which method. The StackTrace object in .Net makes this pretty easy. Here’s a howto… …

Read More “HowTo: determine which object (and method) called another method”

HowTo: read your configfile when using no-touch deployment

Earlier I posted about reading a configfile when using no-touch deployment. Several people have contacted me to post the code, so here it is. private static bool InitializeRemoting() {     string configFile;     configFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;     try     {         //try to read the configfile without tricks first         RemotingConfiguration.Configure(configFile);     }     catch (RemotingException) …

Read More “HowTo: read your configfile when using no-touch deployment”