Why are my images not displaying on my archive web form?

Issue

Why are my images not displaying in my archive web form?

Cause

By default, an image file has a reference to a relative path to your web project folder when it is added in Visual Studio, but once an archive form is generated by WorkflowGen, this archive page is not located in the same web project folder. Therefore, the image link will be broken.

Solution

In the .aspx file, when an image is assigned on the form, the control has the ImageUrl attribute pointing to a relative path.

Example

<asp:Image ID="imgLogo" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/logo.jpg" />

To make sure the archive page can recognize the absolute path of the image file, you need to specify in your code-behind the image path relative to the WorkflowGen folder at the website level.

Example (C# code)

this.imgLogo.ImageUrl = /wfgen/WfApps/Webforms/Project/images/logo.jpg;

You can also store the path to the root folder for all the image files in your web.config file instead of repeating the path for every image used in your web form.

Example

In the web.config, add a new key:

<add key="ImageFolder" value=/wfgen/WfApps/Webforms/Project/images//>

In code-behind:

this.imgLogo.ImageUrl = ConfigurationManager.AppSettings["ImageFolder"] + "logo.jpg";