Table of Contents

Prompt screens

How to create a custom prompt screen using PromptScreenBase

A prompt screen is a small dialog-style screen for collecting a little input before running an action — set a password, name a new item, confirm an export with options. It typically appears as a slide-over panel or a dialog over the current view, with a single primary button (e.g. Create) that runs a command and closes the prompt.

PromptScreen

When to build a prompt screen

Build a prompt screen when an action needs a handful of inputs that don't justify a full edit screen — creating a record from a name, asking for a value before running a command, or confirming an operation with a couple of options. Prompts have no tabs and no info bar; they are a flat list of editors with one confirm action.

Required overrides

Inherit from PromptScreenBase<TModel> in Dynamicweb.CoreUI.Screens, where TModel is a DataViewModelBase.

Override Purpose
string GetScreenName() Title shown at the top of the prompt
void BuildPromptScreen() Add the editors to collect input
CommandBase<TModel>? GetOkCommand() The command run when the user confirms

Laying out editors

A prompt has no tabs — you add editors into named groups with AddComponent / AddComponents:

AddComponent(EditorFor(m => m.Name), "Details");

AddComponents(new[]
{
    EditorFor(m => m.ActiveFrom),
    EditorFor(m => m.ActiveTo),
}, "Publication");

There are three ways to bind an editor, depending on where the value should go:

Helper Binds to Use when
EditorFor(m => m.Property) a model property the value comes from / belongs on the screen's model
EditorForCommand<TCommand, T>(c => c.Property) a property on the OK command the value is a parameter of the command you run
EditorForQuery<TQuery, T>(q => q.Property) a property on the query the value should be fed back into the query

Worked example

A complete prompt screen that asks for a new password and runs a command to set it:

using Dynamicweb.CoreUI.Data;
using Dynamicweb.CoreUI.Editors;
using Dynamicweb.CoreUI.Editors.Inputs;
using Dynamicweb.CoreUI.Screens;

public sealed class UserSetPasswordPromptScreen
    : PromptScreenBase<UserPasswordDataModel>
{
    protected override string GetScreenName() => "Set password";

    protected override void BuildPromptScreen()
    {
        AddComponent(EditorFor(m => m.Password), "New password");
    }

    protected override CommandBase<UserPasswordDataModel>? GetOkCommand()
        => new UserSetPasswordCommand();

    // Use a masked password input instead of the default text editor
    protected override EditorBase? GetEditor(string propertyName) => propertyName switch
    {
        nameof(Model.Password) => new Password(),
        _ => null,
    };
}

You open this prompt from another screen's action — for example, a button on a user list or overview:

NodeAction = OpenSlideOverAction.To<UserSetPasswordPromptScreen>()
    .With(new UserByIdQuery { Id = model.Id })

Binding editors to command parameters

When the value you collect isn't on the model but is a parameter of the command, use EditorForCommand. This prompt collects a name and feeds it straight into the command that creates the page:

public sealed class PageAddPromptScreen : PromptScreenBase<PageDataModel>
{
    protected override string GetScreenName() => "New page";

    protected override void BuildPromptScreen()
    {
        ReloadTypeOnSuccess = ReloadType.Tree;   // refresh the area tree after success

        AddComponent(
            EditorForCommand<PageUpdateNameCommand, string>(c => c.NewName, "Name"),
            "Page settings");

        AddComponents(new[]
        {
            EditorFor(m => m.PublicationState),
            EditorFor(m => m.ActiveFrom),
            EditorFor(m => m.ActiveTo),
        }, "Publication");
    }

    protected override CommandBase<PageDataModel>? GetOkCommand()
        => new PageUpdateNameCommand();
}

Customizing the confirm button and reload behaviour

Member Default What it controls
GetOkActionName() "Create" The label on the primary button
ReloadTypeOnSuccess ReloadType.Workspace What is refreshed after the command succeeds (None, Tree, Workspace, TreeAndWorkspace)
protected override string GetOkActionName() => "Set password";

By default, a successful confirm closes the prompt and reloads according to ReloadTypeOnSuccess. Set ReloadTypeOnSuccess = ReloadType.Tree; in BuildPromptScreen (as above) when the action changes the navigation tree.

Optional overrides

Override What it does
EditorBase? GetEditor(string propertyName) Replace the editor for a model property
EditorBase? GetEditorForCommand(string propertyName) Replace the editor for a command property
EditorBase? GetEditorForQuery(string propertyName) Replace the editor for a query property
ActionBase? GetOkAction() Full control over the confirm action when GetOkCommand isn't enough
void AddDynamicFields(...) Render a model's FieldGroupCollection as editors

Gotchas

  • TModel needs a public parameterless constructor (the new() constraint). Standard DataViewModelBase subclasses satisfy this.
  • Open prompts via an action, not directly. Use OpenSlideOverAction.To<TPrompt>() (slide-over) or OpenDialogAction.To<TPrompt>() (modal). Pass the relevant record with .With(query).
  • No tabs, no info bar. Prompts are intentionally minimal — a flat list of grouped editors plus one confirm button. For anything richer, use an edit screen.
  • The confirm button label defaults to "Create". Override GetOkActionName() for verbs like "Set", "Send", or "Apply".
  • Reload after the command. Set ReloadTypeOnSuccess so the user sees the result — the prompt reloads the workspace by default, but tree-changing actions need ReloadType.Tree or ReloadType.TreeAndWorkspace.
  • Discovery is automatic. Like all screens, prompts are found by the AddInManager; no registration is needed.
To top