SpaContentPlaceHolder

in namespace DotVVM.Framework.Controls

Container which can host a single page application.

Usage & Scenarios

Container which can host a single page application.

To get better understanding how SPAs work, look at the SPA tutorial.

Sample 1: Simple SPA

A simple example of the SPA.

@viewModel DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1.BaseViewModel, DotvvmWeb
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title></title>
</head>
<body>
	
     <menu>
        <li>
          <dot:RouteLink RouteName="SampleA" Text="TextBox sample" />
        </li>
        <li>
          <dot:RouteLink RouteName="SampleB" Text="Literal sample" />
        </li>
    </menu>

    <dot:SpaContentPlaceHolder ID="Sample" />

</body>
</html>
@viewModel DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1.ViewModelA, DotvvmWeb
@masterPage master.dotmaster

<dot:Content ContentPlaceHolderID="Sample">
  <dot:TextBox Text="{value: FirstName}" />
</dot:Content>
@viewModel DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1.ViewModelB, DotvvmWeb
@masterPage master.dotmaster

<dot:Content ContentPlaceHolderID="Sample">
  {{value: Text}}
</dot:Content>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DotVVM.Framework.Configuration;

namespace DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1
{
    public class Startup : IDotvvmStartup
    {
        public void Configure(DotvvmConfiguration config, string applicationPath)
        {
            config.RouteTable.Add("SampleA", "SampleA", "SampleA.dothtml", null);
            config.RouteTable.Add("SampleB", "SampleB/{Id}", "SampleB.dothtml", null);
        }
    }
}
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1
{
    public class ViewModelA : BaseViewModel
    {

        public string FirstName { get; set; } = "Tomas";

    }
}
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1
{
    public class ViewModelB : BaseViewModel
    {

        public string Text { get; set; } = "Test value";

    }
}
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.SpaContentPlaceHolder.sample1
{
    public abstract class BaseViewModel : DotvvmViewModelBase
    {
        
    }
}

Properties

Name Type Description Notes Default Value
property icon DefaultRouteName String Gets or sets the default name of the route that should be loaded when there is no hash part in the URL.
attribute
inner element
static value
bindable
default
null
property icon PrefixRouteName String Gets or sets the name of the route defining the base URL of the SPA (the part of the URL before the hash). If this property is not set, the URL of the first page using the SpaContentPlaceHolder will stay before the hash mark.
attribute
inner element
static value
bindable
default
null
property icon RenderWrapperTag Boolean Gets or sets whether the control should render a wrapper element.
attribute
inner element
static value
bindable
default
False
property icon UseHistoryApi Boolean? Gets or sets whether navigation in the SPA pages should use History API. If this property is not set, settings from DotvvmConfiguration is used.
attribute
inner element
static value
bindable
default
null
property icon WrapperTagName String Gets or sets the name of the tag that wraps the Repeater.
attribute
inner element
static value
bindable
default
div

HTML produced by the control