Class ButtonViewModel
- Namespace
- Dynamicweb.Frontend
- Assembly
- Dynamicweb.dll
The ButtonViewModel class is a specialized view model for handling CTA buttons. It extends from the ViewModelBase class.
- Inheritance
-
Button
View Model
- Inherited Members
Examples
Here's how you can use the ButtonViewModel in a Razor view:
@if (Model.Item.TryGetButton("SecondButton", out ButtonViewModel secondButton)) {
<a href="@secondButton.Link.Url" class="btn btn-@secondButton.Style" data-dw-button="@secondButton.Style">@secondButton.Label</a>
}
Properties
Label
Gets or sets the label of the button, e.g. "Read more".
Property Value
- string
The label.
Link
Gets or sets the link for the button if specified.
Property Value
- Link
View Model The link for the button.
Style
Gets or sets the style of the button.
Property Value
- string
The style of the button.
Remarks
One of these 5 styles (cannot be changed):
- "primary"
- "outline-primary"
- "secondary"
- "outline-secondary"
- "link"