@page "/modal"
@using Connected.Components;
@using Connected.Enums;
@using Connected.Models.Modal;
@using Connected.Models;
@using Connected.Services;
@using Connected.Utilities;
@inject ModalDialogService modalDialog
MODAL DIALOG EXAMPLE
Modal result: @test_modal_result
Value: @value.ToString()
@code {
int value = 0;
string test_modal_result = string.Empty;
ModalOptions options = new ModalOptions();
public void OpenModalDialog()
{
modalDialog.ShowDialog(
/*
MODAL TITLE
*
*/
"Title",
/*
MODAL CONTENT !!!starting with @
*
*/
@
Change the number input and watch the value variable behind the modal change
,
/*
MODAL BUTTONS WITH ACTIONS
*
*/
new List()
{
new ModalButton(
new Event(ChangeText, new object[]{"OK clicked"}), //event triggered on button click
"OK", //button text
ModalButtonType.OkButton, //button type: OK, Cancel, Regular
true //close modal on click
),
new ModalButton(
new Event(ChangeText, new object[]{"Cancel clicked"}), //event triggered on button click - first parameter = method name, second parameter = method parameters --> array of objects
"Cancel", //button text
ModalButtonType.CancelButton, //button type: OK, Cancel, Regular
true //close modal on click
),
new ModalButton(
new Event(ChangeText, new object[]{"Regular clicked"}), //event triggered on button click - first parameter = method name, second parameter = method parameters --> array of objects
"Click me", //button text
ModalButtonType.RegularButton, //button type: OK, Cancel, Regular
true //close modal on click
)
},
/*
MODAL OPTIONS
*
*/
new ModalOptions(false,true,false)); //modal dialog options - optional
}
private void ChangeValue(int val)
{
value = val;
StateHasChanged();
}
public void ChangeText(string some_parameter)
{
test_modal_result = some_parameter;
StateHasChanged();
}
}