Tips and troubleshooting when using csXImage in a browser with Javascript.

csXImage can run inside Internet Explorer (for Windows) and in this way it provides some powerful functionality to web and intranet applications. It can sometimes be difficult to get started with this type of application, especially when deploying the web page from a remote server and we aim to cover some of the important questions here. The error messages produced by client side Javascript are often unhelpful so it is important to know the causes of some of these errors.

It is important to realise that an ActiveX control such as csXImage must run in Windows and the only browser which currently supports these controls is Microsoft Internet Explorer. The operating system of the server is not relevant.

Licensing, Object Tags and Versions

We have a separate page covering these issues - HERE. That page includes essential information on how to place the Licence Package File on the server so that each client can run the control at run time using the design time licence that is on the server. It also describes how to call the csXImage control using an <object> tag, which requires a different class ID depending on whether it is the full or trial version.

Common Mistakes

Some of the common mistakes which prevent csXImage from running in a browser are as follows:

1. Not following the instructions described in the link above. The Licence Package File must be present on the server and the <object> tag which calls it must be before the <object> tag which creates the csXImage instance.

Here is a repeat of the HTML code used to call up the .lpk file:

<object classid="clsid:5220cb21-c88d-11cf-b347-00aa00a28331">
  <param name="LPKPath" value="... relative path to .lpk file ...">

This is using a DLL which is installed as part of Windows called the Licence Manager and it has its own class ID and one parameter called LPKPath which points to the .lpk file. Do not confuse this class ID with the class ID used by the csXImage control and do not attempt to include the LPKPath inside the object tag for the csXImage control.

Another potential error with LPK files arises because the LPK file must be created wih the same version of the ActiveX control which uses it. We now provide the LPK file with the csXImage installation to make it easier to use. If you ever update the version of csXImage you must also replace the LPK file. You can create your own LPK file using the LPK File Generation Tool but this works with the registered version of the ActiveX control on the machine that runs the Tool, so you must make sure that the control on the web site is the same as the registered version.

2. Syntax errors. A Javascript syntax error that we see frequently involves the use of brackets when calling methods. A method call requires brackets, even if there are no parameters. Adding brackets when reading a property will produce an error. Either error, adding brackets when they are not required or missing them when they are, will give the error:

Object doesn't support this property or method

This is the same error that is shown when the object has not been instantiated and can lead to a long search for an error in the wrong place.

Some examples of methods and properties and the correct use of brackets are as follows (we will assume that a csXImage object has been created called csxi).


CurrentDevice = csxi.CurrentTwainDevice;

SelectTwainDevice is a method and so it requires brackets, CurrentTwainDevice is a property and so must not have brackets after it.

3. Nesting the object tag inside a form tag. If the object tag which calls the csXImage object is nested inside a form tag, the syntax is changed and the csXImage object must be called as a sub property of the form.

For example, if the form is called "form1" and the csXImage object is called "csxi", the Javascript code to load an image using the dialogue box would be:


4. Using Enumerated Contants. Clientside Javascript does not recognise the enumerated constants defined in csXImage. Please refer to Section 19 of the instructions for the numeric equivalents of the enumerated constants and use those. For example, to set the ColorFormat property to 24 bit the constant cf24bit is not recognised and the value zero must be used instead:

csxi.ColorFormat = 0;

5. Dynamically resizing the control. Unlike most programming environments clientside Javascript will not allow the csXImage control to be resized dynamically using the Width and Height properties. Instead, set the width and height through the style property. = 300; = 200;

6. Case sensitivity on Linux/UNIX servers. The OCX or CAB file and the LPK file must have the same case sensitivity as the names and paths inside the object tags, on a Linux or Unix server. If there is a difference the control will not load. This is not relevant on Windows servers because these are not case sensitive.

Running the application locally compared with deploying from a remote server

If our installer has been run on the client machine it will have copied the OCX file and the licence file to that machine and registered the csXImage control. This prevents the need for the LPK file, and the control is not downloaded by the browser when the page is first loaded. This means that many of the problems related to deploying from a remote server, such as the licensing issues and the security settings in the browser, will not apply. It is therefore important to test the application in a real deployment situation at some point and we would recommend that anyone thinking of buying the full version of csXImage makes the appropriate tests with the trial version first.

There are no restrictions on our trial version but with the full version it might be against our licence terms to make multiple installations using our installer as it copies the licence file each time it runs.


This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.