Skip to content

Commit 84c91ba

Browse files
docs(dialog): add samples for customizing predefined dialog buttons (#1890)
1 parent 7557a1f commit 84c91ba

File tree

1 file changed

+34
-10
lines changed

1 file changed

+34
-10
lines changed

components/dialog/predefined.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,32 @@ The alert dialog usually shows the user that something went wrong, such as a maj
3838
3939
<TelerikButton OnClick="@ShowAlert">Show Alert</TelerikButton>
4040
<TelerikButton OnClick="@ShowAlertWithTitle">Show Alert with Custom Title</TelerikButton>
41+
<TelerikButton OnClick="@ShowAlertWithTitleAndButton">Show Alert with Custom Title and Custom Button</TelerikButton>
4142
4243
@code {
4344
[CascadingParameter]
44-
public DialogFactory Dialogs { get; set; }
45+
private DialogFactory Dialogs { get; set; }
4546
46-
public async Task ShowAlert()
47+
private async Task ShowAlert()
4748
{
4849
await Dialogs.AlertAsync("Something went wrong!");
4950
5051
Console.WriteLine("The user dismissed the alert box.");
5152
}
5253
53-
async Task ShowAlertWithTitle()
54+
private async Task ShowAlertWithTitle()
5455
{
5556
await Dialogs.AlertAsync("Something went wrong!", "Read this!");
5657
5758
Console.WriteLine("The user dismissed the alert box with the custom title.");
5859
}
60+
61+
private async Task ShowAlertWithTitleAndButton()
62+
{
63+
await Dialogs.AlertAsync("Something went wrong!", "Read this!", "DONE");
64+
65+
Console.WriteLine("The user dismissed the alert box with the custom title and custom button.");
66+
}
5967
}
6068
````
6169

@@ -72,12 +80,13 @@ The confirm dialog returns a `bool` value that indicates which button the user c
7280
7381
<TelerikButton OnClick="@ShowConfirm">Show Confirm</TelerikButton>
7482
<TelerikButton OnClick="@ShowConfirmWithTitle">Show Confirm with Custom Title</TelerikButton>
83+
<TelerikButton OnClick="@ShowConfirmWithTitleAndButtons">Show Confirm with Custom Title and Custom Buttons</TelerikButton>
7584
7685
@code {
7786
[CascadingParameter]
78-
public DialogFactory Dialogs { get; set; }
87+
private DialogFactory Dialogs { get; set; }
7988
80-
public async Task ShowConfirm()
89+
private async Task ShowConfirm()
8190
{
8291
bool isConfirmed = await Dialogs.ConfirmAsync("Are you sure?");
8392
@@ -91,12 +100,19 @@ The confirm dialog returns a `bool` value that indicates which button the user c
91100
}
92101
}
93102
94-
async Task ShowConfirmWithTitle()
103+
private async Task ShowConfirmWithTitle()
95104
{
96105
bool isConfirmed = await Dialogs.ConfirmAsync("Are you sure?", "Confirmation!");
97106
98107
Console.WriteLine($"The user is sure: {isConfirmed}.");
99108
}
109+
110+
private async Task ShowConfirmWithTitleAndButtons()
111+
{
112+
bool isConfirmed = await Dialogs.ConfirmAsync("Are you sure?", "Confirmation!", "YES, I'm sure", "NO, I'm not sure");
113+
114+
Console.WriteLine($"The user is sure: {isConfirmed}.");
115+
}
100116
}
101117
````
102118

@@ -115,12 +131,13 @@ The prompt dialog returns a `string` that the user enters when they press `OK`,
115131
<TelerikButton OnClick="@ShowPrompt">Show Prompt</TelerikButton>
116132
<TelerikButton OnClick="@ShowPromptWithTitle">Show Prompt with Custom Title</TelerikButton>
117133
<TelerikButton OnClick="@ShowPromptWithTitleAndDefaultText">Show Prompt with Title and Default Input Text</TelerikButton>
134+
<TelerikButton OnClick="@ShowPromptWithTitleDefaultTextAndButtons">Show Prompt with Title, Default Input Text and Custom Buttons</TelerikButton>
118135
119136
@code {
120137
[CascadingParameter]
121-
public DialogFactory Dialogs { get; set; }
138+
private DialogFactory Dialogs { get; set; }
122139
123-
public async Task ShowPrompt()
140+
private async Task ShowPrompt()
124141
{
125142
string userInput = await Dialogs.PromptAsync("Enter your answer.");
126143
@@ -134,19 +151,26 @@ The prompt dialog returns a `string` that the user enters when they press `OK`,
134151
}
135152
}
136153
137-
async Task ShowPromptWithTitle()
154+
private async Task ShowPromptWithTitle()
138155
{
139156
string userInput = await Dialogs.PromptAsync("Enter answer:", "Input needed");
140157
141158
Console.WriteLine($"The user answer: {userInput}");
142159
}
143160
144-
async Task ShowPromptWithTitleAndDefaultText()
161+
private async Task ShowPromptWithTitleAndDefaultText()
145162
{
146163
string userInput = await Dialogs.PromptAsync("Enter answer:", "Input needed", "Default Text");
147164
148165
Console.WriteLine($"The user answer: {userInput}");
149166
}
167+
168+
private async Task ShowPromptWithTitleDefaultTextAndButtons()
169+
{
170+
string userInput = await Dialogs.PromptAsync("Enter answer:", "Input needed", "Default Text", "READY", "REJECT");
171+
172+
Console.WriteLine($"The user answer: {userInput}");
173+
}
150174
}
151175
````
152176

0 commit comments

Comments
 (0)