forked from FritzAndFriends/BlazorWebFormsComponents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButtonBaseComponent.cs
More file actions
47 lines (37 loc) · 1014 Bytes
/
ButtonBaseComponent.cs
File metadata and controls
47 lines (37 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
namespace BlazorWebFormsComponents
{
public abstract class ButtonBaseComponent : BaseStyledComponent, IButtonComponent
{
[Parameter]
public bool CausesValidation { get; set; } = true;
[Parameter]
public string CommandName { get; set; }
[Parameter]
public object CommandArgument { get; set; }
[Parameter]
public virtual string PostBackUrl { get; set; }
[Parameter]
public string Text { get; set; }
[Parameter]
public string OnClientClick { get; set; }
[Parameter]
public EventCallback<MouseEventArgs> OnClick { get; set; }
[Parameter]
public EventCallback<CommandEventArgs> OnCommand { get; set; }
protected void Click()
{
if (!string.IsNullOrEmpty(CommandName))
{
var args = new CommandEventArgs(CommandName, CommandArgument);
OnCommand.InvokeAsync(args);
OnBubbledEvent(this, args);
}
else
{
OnClick.InvokeAsync(new MouseEventArgs());
}
}
}
}