LinkButton
in namespace DotVVM.Framework.Controls
Renders the hyperlink which behaves like a button.
Usage & Scenarios
Renders the hyperlink which behaves like a button.
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="Switch"/>
<dot:LinkButton Click="{command: DoSomething()}" Text="Link Button with Enabled binding" Enabled="{value: Enabled}"/>
<dot:LinkButton Click="{command: DoSomething()}" Text="Link Button with Visible binding" 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()
{
}
}
}
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 | |
Enabled | Boolean | Gets or sets a value indicating whether the button is enabled and can be clicked on. |
attribute
static value
bindable
|
True | |
ID | String | Gets or sets the unique control ID. |
attribute
static value
|
null | |
InnerText | String | Gets or sets the inner text of the HTML element. |
attribute
static value
bindable
|
null | |
Text | String | Gets or sets the text on the button. |
attribute
static value
bindable
|
||
Visible | Boolean | Gets or sets whether the control is visible. |
attribute
bindable
|
True |
Events
Name | Type | Description | |
---|---|---|---|
Click | Command | Gets or sets the command that will be triggered when the button is clicked. |
HTML produced by the control
The control renders a hyperlink:
<a href="#" onclick="...">Text or inner content</a>