combit List & Label 29 - .NET Help
Programming Introduction / Tutorial / Web Reporting Overview / Use of the Ad-hoc Designer
In This Topic
    Use of the Ad-hoc Designer
    In This Topic



    The following section describes the concepts of the Ad-hoc Designer as well as the necessary steps for its implementation and tips & tricks.

    For a complete implementation and use of the Ad-hoc Designer, see the sample project "Ad-hoc Designer Sample", which comes with ASP. NET samples. Further details can also be found in the two assemblies combit.Reporting.AdhocDesign Namespace und combit.Reporting.AdhocDesign.Web.



    The Ad-hoc Designer is not a replacement for the Web Designer

    It is a completely browser-based application (HTML+Javascript) that allows you to design basic reports like simple tables or charts very quickly. It offers only the most important features of the full List & Label Designer, but does not require an installation on the client computer like the Web Designer (see also Use of the Web Designer) does. Furthermore it provides a simplified user interface that can be used on any modern device, operating system and browser.


    The projects of the Ad-hoc Designer are saved in a special file format

    A project file that has been designed with the Ad-hoc Designer can be used like a regular List & Label project for exporting or printing it. You can also open it in the classic Designer to customize the more advanced properties, however a project that has been created or modified with the classic Designer cannot be loaded in the Ad-hoc Designer.


    There is an Ad-hoc Designer session for every instance of the Ad-hoc Designer

    Every time a user opens the Ad-hoc Designer in the browser, an IAdhocDesignerSession object on the server is created that manages this certain instance of the Designer. This session object loads the project if the Designer on the client needs it and stores the project when the client sends a project file to the server to save it. So usually for every browser tab that has the Ad-hoc Designer loaded, there is one Ad-hoc Designer session on the server which exists until the designer on the client is closed.

    Integrating the Ad-hoc Designer into your application means connecting that session to the rest of your application to handle operations like loading and saving the project or creating the data source.


    The Ad-hoc Designer is an application within your application

    It is based on the ASP.NET MVC framework, but has it's own routes and controllers that you don't need to take care of. Please note that it is not a component that you can embed on your page (or view). The Ad-hoc Designer is opened by navigating (redirecting) to a special URL, so it always uses the whole page. If you would like to show it as part of an other page, you need to load it in an iframe.


     How to Add it to Your Application (in 3 Steps)

    Step 1: Add the required dependencies

    To integrate the Ad-hoc Designer in your ASP.NET project you first need to add the following NuGet packages:

    • Newtonsoft.Json (13.0.1 or newer)
    • Microsoft.AspNet.Mvc (5.2.7 or newer)
    • Microsoft.AspNet.Web.Optimization (1.1.3 or newer)
    • RazorGenerator.Mvc (2.4.9 or newer)

    And then reference the following assemblies of List & Label:

    • combit.ListLabel29.dll
    • combit.ListLabel29.AdhocDesign.dll
    • combit.ListLabel29.AdhocDesign.Web.dll
    The RazorGenerator.Mvc package adds a RazorGeneratorMvcStart.cs file to your project. Please delete this file.


    Step 2: Do some configuration

    The further procedure differs for .NET 6/.NET 7/.NET 8 and .NET 4.8.


    .NET 6/.NET 7/.NET 8:

    In the startup.cs file, add the following lines to the end of the Configure method:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        // do some other stuff here
        // ...
        app.UseAdhocDesigner(c => { });

    And in the ConfigureServices method, add this line:

    public void ConfigureServices(IServiceCollection services)
        // do some other stuff here
        // ...


    .NET 4.8:

    The Ad-hoc Designer is based on ASP.NET MVC. When your application is starting, you need to set up the routing and some other configuration of the Ad-hoc Designer:

    • Call AdhocWebDesigner.RegisterRoutes() before (!) registering your own routes (see the RouteConfig.cs file of this project)
    • Call AdhocWebDesigner.Setup(...) during the application startup (see the Application_Start() method in the global.asax file). Many options are defined per-session, but the global options can be configured with this call


    Step 3: Open the Ad-hoc Designer

    As mentioned above, there is one IAdhocDesignerSession object on the server for each active Ad-hoc Designer on a client. Before the Ad-hoc Designer can be opened on the client, you need to create a new object of the IAdhocDesignerSession interface.

    We recommend to use one of the included Ad-hoc-Session types that handle the load & save operations for you:

    • Call AdhocDesignerSession.FromFile(...) to create an Ad-hoc Designer session for a project file in the file system
    • Call AdhocDesignerSession.FromRepositoryItem(...) to create an Ad-hoc Designer session for a project that is stored in a repository
    Finally you call this.RedirectToAdhocDesigner(session) in an action of your MVC controller to redirect the request to a new Ad-hoc Designer (import the combit.Reporting.AdhocDesign.Web namespace to make this extension method available). You can find an example of this in the supplied ASP. NET sample project "C# Ad-hoc Designer" underHomeController.OpenNewProject().


     Tips & Tricks

    If you need more control when creating, loading or saving a project

    Create your own Ad-hoc Designer session type and let it inherit from AdhocDesignerSessionBase. Many methods are virtual and may be overriden, e.g. when you want to customize the defaults for a new project.


    If you need more control over the lifetimes and management of the Ad-hoc Designer sessions

    Create your own implementation of the IAdhocDesignerSessionManager interface and pass it to the AdhocDesignerWeb.Setup(...) method (see Step 2).