MobiScroll
Namespace: Wisej.Web.Ext.MobiScroll
Assembly: Wisej.Web.Ext.MobiScroll (4.1.0.0)
Provides static methods to show the MobiScroll notifications: alert, confirm and prompt dialogs, and snackbars.
- C#
- VB.NET
public static class MobiScroll
Public Class MobiScroll
The methods call the MobiScroll JavaScript library in the browser, which must already be loaded. The library is loaded when the first MobiScroll widget or component of this extension is created on the client.
Example:
The following example asks for a confirmation and shows a snackbar when the user confirms.
private async void buttonDelete_Click(object sender, EventArgs e)
{
if (await MobiScroll.ConfirmAsync("Do you want to delete the selected order?", "Delete order", "Delete"))
{
DeleteSelectedOrder();
MobiScroll.Snackbar("The order has been deleted.", color: ThemeColor.Success);
}
}
Methods
AlertAsync(message, title, okText, display)
Shows an alert dialog that notifies or warns the user about something. It contains a single button which closes the alert.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| title | String | The title of the dialog. |
| okText | String | The text of the button that closes the dialog. The default is "OK". |
| display | String | The position of the dialog; it is the value of the MobiScroll display option, i.e. "center", "top" or "bottom". The default is "center". |
Returns: Task. A task that completes when the user closes the dialog.
Example:
The following example waits for the user to close the alert before updating the page.
await MobiScroll.AlertAsync("The backup has been completed.", "Backup", "Close");
this.labelStatus.Text = "Ready";
Confirm(message, title, okText, cancelText, display, callback)
Shows a confirmation dialog which is used when it is required to confirm an action. It has two buttons, one of which confirms the action, and the other rejects it.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| title | String | The title of the dialog. |
| okText | String | The text of the button that confirms the action. The default is "OK". |
| cancelText | String | The text of the button that rejects the action. The default is "Cancel". |
| display | String | The position of the dialog; it is the value of the MobiScroll display option, i.e. "center", "top" or "bottom". The default is "center". |
| callback | Action<Object> | Optional function invoked when the dialog is closed. It receives true when the user confirmed the action, otherwise false. |
Example:
The following example deletes an order only when the user confirms.
MobiScroll.Confirm(
"Do you want to delete the selected order?",
"Delete order",
okText: "Delete",
callback: (confirmed) =>
{
if (confirmed)
DeleteSelectedOrder();
});
ConfirmAsync(message, title, okText, cancelText, display)
Shows a confirmation dialog which is used when it is required to confirm an action. It has two buttons, one of which confirms the action, and the other rejects it.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| title | String | The title of the dialog. |
| okText | String | The text of the button that confirms the action. The default is "OK". |
| cancelText | String | The text of the button that rejects the action. The default is "Cancel". |
| display | String | The position of the dialog; it is the value of the MobiScroll display option, i.e. "center", "top" or "bottom". The default is "center". |
Returns: Task<Boolean>. A task that returns true when the user confirmed the action, otherwise false.
Example:
The following example closes the form only when the user agrees to discard the changes.
var discard = await MobiScroll.ConfirmAsync(
"You have unsaved changes.",
"Close the document?",
"Discard",
"Keep editing");
if (discard)
this.Close();
Prompt(message, title, okText, cancelText, placeholder, label, inputType, value, display, callback)
Shows a prompt dialog which is used when it is required to get some data from the user, e.g. a password confirmation. It has two buttons, one of which submits the entered data, the other one cancels the dialog.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| title | String | The title of the dialog. |
| okText | String | The text of the button that submits the entered data. The default is "OK". |
| cancelText | String | The text of the button that cancels the dialog. The default is "Cancel". |
| placeholder | String | The placeholder text shown in the input while it is empty. |
| label | String | The label of the input. |
| inputType | String | The type of the input, i.e. "text", "password" or "email". |
| value | String | The initial value of the input. |
| display | String | The position of the dialog; it is the value of the MobiScroll display option, i.e. "center", "top" or "bottom". The default is "center". |
| callback | Action<Object> | Optional function invoked when the dialog is closed. It receives the text entered by the user, or null when the dialog was cancelled. |
Example:
The following example asks for a password and verifies it when the user submits the dialog.
MobiScroll.Prompt(
"Enter your password to continue.",
"Confirm your identity",
label: "Password",
inputType: "password",
callback: (password) =>
{
if (password != null)
VerifyPassword((string)password);
});
PromptAsync(message, title, okText, cancelText, placeholder, label, inputType, value, display)
Shows a prompt dialog which is used when it is required to get some data from the user, e.g. a password confirmation. It has two buttons, one of which submits the entered data, the other one cancels the dialog.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| title | String | The title of the dialog. |
| okText | String | The text of the button that submits the entered data. The default is "OK". |
| cancelText | String | The text of the button that cancels the dialog. The default is "Cancel". |
| placeholder | String | The placeholder text shown in the input while it is empty. |
| label | String | The label of the input. |
| inputType | String | The type of the input, i.e. "text", "password" or "email". |
| value | String | The initial value of the input. |
| display | String | The position of the dialog; it is the value of the MobiScroll display option, i.e. "center", "top" or "bottom". The default is "center". |
Returns: Task<String>. A task that returns the text entered by the user, or null when the dialog was cancelled.
Example:
The following example asks for the name of a new folder and creates it when the user submits a name.
var name = await MobiScroll.PromptAsync(
"Enter the name of the new folder.",
"New folder",
okText: "Create",
placeholder: "Folder name");
if (!String.IsNullOrEmpty(name))
CreateFolder(name);
Snackbar(message, duration, color, buttonText, buttonIconSource, display, callback)
Shows a snackbar that provides brief feedback after an action through a message at the bottom of the screen. A snackbar may contain an action, such as "Undo" or "Retry". Snackbars don't lock the app's main interface and are automatically dismissed after a while.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| duration | Int32 | The time, in milliseconds, after which the snackbar is dismissed. The default is 3000. |
| color | Nullable<ThemeColor> | The predefined color of the snackbar, or null to use the default color of the theme. The default is Primary. |
| buttonText | String | The text of the action button, or null to show the snackbar without a button. |
| buttonIconSource | String | The name of the MobiScroll icon to show on the action button. It is used only when buttonText is specified. |
| display | String | The position of the snackbar; it is the value of the MobiScroll display option, i.e. "bottom" or "top". The default is "bottom". |
| callback | Action<Object> | Optional function invoked when the snackbar is closed. It receives an object with the field type set to "button" when the user pressed the action button, or to "timeout" when the snackbar was dismissed. |
Example:
The following example shows a snackbar with the "Undo" action and restores the message when the user presses the button.
MobiScroll.Snackbar(
"The message has been archived.",
color: ThemeColor.Success,
buttonText: "Undo",
callback: (result) =>
{
if (((dynamic)result).type == "button")
RestoreMessage();
});
SnackbarAsync(message, duration, color, buttonText, buttonIconSource, display)
Shows a snackbar that provides brief feedback after an action through a message at the bottom of the screen. A snackbar may contain an action, such as "Undo" or "Retry". Snackbars don't lock the app's main interface and are automatically dismissed after a while.
| Parameter | Type | Description |
|---|---|---|
| message | String | The message to display. |
| duration | Int32 | The time, in milliseconds, after which the snackbar is dismissed. The default is 3000. |
| color | Nullable<ThemeColor> | The predefined color of the snackbar, or null to use the default color of the theme. The default is Primary. |
| buttonText | String | The text of the action button, or null to show the snackbar without a button. |
| buttonIconSource | String | The name of the MobiScroll icon to show on the action button. It is used only when buttonText is specified. |
| display | String | The position of the snackbar; it is the value of the MobiScroll display option, i.e. "bottom" or "top". The default is "bottom". |
Returns: Task<Object>. A task that returns a dynamic object with the field type set to "button" when the user pressed the action button, or to "timeout" when the snackbar was dismissed.
Example:
The following example shows a snackbar with the "Retry" action and waits for it to close.
var result = await MobiScroll.SnackbarAsync(
"The connection has been lost.",
duration: 5000,
color: ThemeColor.Danger,
buttonText: "Retry");
if (result.type == "button")
Reconnect();