Create New/Empty Project for the Web Designer

Introduction

The Web Designer used in ASP.NET applications can handle projects in two different modes.

File-Based Default Mode

One is the default mode, in which file-based projects are used directly. However, this mode has some disadvantages such as the lack of support for additional files. This means that all functions of the (Desktop) Designer that require additional files (besides the main project) are deactivated in the Web Designer. The reason is, it cannot be guaranteed that the selected local file paths are valid on both the client and the server. This affects drilldown projects, project templates, non-embedded images and PDF files, etc.

Stream-Based Repository Mode

The second mode for working with projects in the Web Designer is the so-called Repository Mode, which is highly recommended due to the numerous restrictions of the file-based standard mode. In this mode, any file access is redirected to a virtual file system (stream-based) which allows you to manage all project relevant files using your own code - for example, in a SQLite database.

Implementation

However, to make it possible to start the Web Designer with a new, empty project, different preparatory work must be carried out depending on the mode. Basically it is only a matter of assigning suitable values to the two properties AutoProjectType and AutoProjectFile.

File-Based Default Mode

It is required that the new/empty project file is first created on the server side in the file system. Only then can the Web Designer obtain this file from the server at startup and use it locally on the client. The Object Model (DOM) is used to create an empty project file:

// create the List & Label object, set required options,
// set the LicensingInfo property, define the used data source etc. 
//...

// we need to create the project file (empty!) with DOM on the server-side first
String projectFileName = Server.MapPath("~/App_Data/myNewProject.lst");
using (ProjectList domNewProject = new ProjectList(LL))
{
    domNewProject.Open(projectFileName, LlDomFileMode.Create);
    domNewProject.Save();
    domNewProject.Close();
}

// pass the newly created project to the Web Designer
LL.AutoProjectFile = projectFileName;

// also define the matching project type
LL.AutoProjectType = LL.Core.LlUtilsGetProjectType(projectFileName);

// attach the prepared List & Label object to the Web Designer component
//...

Stream-Based Repository Mode

To make working with the repository easier there is a helpful class RepositoryImportUtil. It adds an easy way to create a new project using CreateNewProject:

// create the List & Label object, set required options,
// set the LicensingInfo property, define the repository, 
// define the used data source etc. 
//...

// we need to create a new/empty repository item
LlProject projectType = LlProject.List;
using (RepositoryImportUtil importUtil = new RepositoryImportUtil(RepositoryHelper.GetCurrentRepository()))
{
    reportRepositoryID = importUtil.CreateNewProject(projectType, null);
}

// define new create project (its repository ID) to use in the Web Designer
LL.AutoProjectFile = reportRepositoryID;

// also define the matching project type
LL.AutoProjectType = projectType;

// attach the prepared List & Label object to the Web Designer component
//...

Recommendation

No matter which mode you ultimately choose, the snippets above will start the Web Designer with a new/empty project. Nevertheless, we recommended to use the stream-based mode because of the extended feature set.