Category Archives: Software Development

Mainly Microsoft .NET related articles

HTML: Calculating the height of a DIV-Container

Today i had to calculate the height of a DIV-Container in Javascript:

1. Select the DIV-Container to calculate carefully, if you have a div container only with sub div containers in it and no other container, select the sub containers for calculation, if you have to know the outer div containers height, sum up both sub containers height.

2. If you haven’t yet, assign IDs to the div containers

3. use this code to get the height of the div-container:


var divelement = document.getElementById("divID");
calculatedHeight = divelement.offsetHeight;

It is important to use “offsetHeight” and not “clientHeight” as the Internet Explorer (version 7) does not parse this correctly.

The code


var divelement = document.getElementById("divID");
calculatedHeight = divelement.clientHeight;

does not work in all circumstances.

Windows Workflow Foundation: invokeWebService URL manipulating at runtime

The invokeWebservice Activity inside the Microsoft Workflow Foundation (WF) is a nice helper to get or send data from/to a webservice.

In Visual Studio 2008 you normally add the Webservice reference by referencing a URL and in most cases this URL will be a pointer to a development server. In production use you want to configure this URL of course. And here the pain begins. The invokeWebService Activity does not allow to edit the URL property at runtime. Instead you have to modify the runtime instance of the used proxy class.

You can do this by using this method in the invoking event of the activiy:

/// 
/// Called before the webservice is invoked. Here the URL can be configured during runtime by manipulating the proxy class
/// 
///

///
Webservice EventArgs including the instance of the proxy class
private void invokeGetMails_Invoking(System.Object sender, System.Workflow.Activities.InvokeWebServiceEventArgs e)
{
     service_ns.service proxy;
     proxy = (service_ns.service)e.WebServiceProxy;
     proxy.Url = this.wsUrl;

}