DOT

VVM

 DOCS

Version: 1.0 | 1.1 |

LinkButton

in namespace DotVVM.Framework.Controls

Renders the hyperlink which behaves like a button.

Properties

Name Type Description Notes Default Value
Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
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
inner element
static value
bindable
default
Enabled Boolean Gets or sets a value indicating whether the button is enabled and can be clicked on.
attribute
inner element
static value
bindable
default
True
ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
Text String Gets or sets the text on the button.
attribute
inner element
static value
bindable
default
Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True

Events

Name Type Description
Click Command Gets or sets the command that will be triggered when the button is clicked.

Usage & Scenarios

Renders the hyperlink which behaves like a button.

HTML Rendered by the Control

The control renders a hyperlink:

<a href="#" onclick="...">Text or inner content</a>

Sample 1: Basic LinkButton

The LinkButton control can use the Text property or the inner content to specify what's inside.

The Click event specifies, which method in the viewmodel will be triggered.

<dot:LinkButton Click="{command: DoSomething()}" Text="Simple Link Button" />

<dot:LinkButton Click="{command: DeleteSomething()}">
  <img src="~/images/delete.png" /> Delete
</dot:LinkButton>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.LinkButton.sample1
{
    public class ViewModel : DotvvmViewModelBase
    {
        public void DoSomething()
        {
            // do what you have to do
        }

        public void DeleteSomething()
        {
            // do what you have to do
        }
    }
}

Sample 2: Disable or Hide the LinkButton

To disable or enable the button, use the Enabled property. It supports the data-binding.

It's also possible to hide the button completely by using the Visible property.

<dot:LinkButton Click="{command: Switch()}" Text="Enabled Link Button"/>

<dot:LinkButton Click="{command: DoSomething()}" Text="Enabled Link Button" Enabled="{value: Enabled}"/>

<dot:LinkButton Click="{command: DoSomething()}" Text="Hidden Link Button" Visible="{value: Enabled}"/>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.builtin.LinkButton.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public bool Enabled { get; set; } = true;

        public void Switch()
        {
            Enabled = !Enabled;
        }

        public void DoSomething()
        {
            
        }

    }
}

Suggestions


Help & Contribute

The documentation is maintained on GitHub.
We'll be happy if you edit the page and create a pull request.

Send message