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 | |
---|---|---|---|---|---|
Attributes | Dictionary<String,Object> |
attribute
static value
|
null | ||
ClientIDMode | ClientIDMode | Gets or sets the client ID generation algorithm. |
attribute
static value
|
Static | |
DataContext | Object | Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value. |
attribute
static value
bindable
|
null | |
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
static value
|
null | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
bindable
|
null | |
IncludeInPage | Boolean | Gets or sets whether the control is included in the DOM of the page. |
attribute
bindable
|
True | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
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
static value
|
null | |
RenderWrapperTag | Boolean | Gets or sets whether the control should render a wrapper element. |
attribute
static value
|
False | |
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
static value
|
null | |
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True | |
WrapperTagName | String | Gets or sets the name of the tag that wraps the Repeater. |
attribute
static value
|
div |