Visual Basic (Declaration) | |
---|---|
<LicenseProviderAttribute(System.ComponentModel.LicenseProvider)> Public Class LiveMessageBox Inherits System.Web.UI.Control Implements ILiveControl |
Visual Basic (Usage) | Copy Code |
---|---|
Dim instance As LiveMessageBox |
C# | |
---|---|
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)] public class LiveMessageBox : System.Web.UI.Control, ILiveControl |
C++/CLI | |
---|---|
[LicenseProviderAttribute(System.ComponentModel.LicenseProvider)] public ref class LiveMessageBox : public System.Web.UI.Control, ILiveControl |
The following example demonstrates using a LiveMessageBox in combination with a Live List control.
Visual Basic | Copy Code |
---|---|
'In this example, items are added to a Live List control using an ArrayList when a LiveButton is pressed 'The items include different LiveMessageBox Dialog Types 'When one of the Types is selected in the List, the MessageBox is shown 'LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList Private Sub LiveButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton1.Click 'Create a new ArrayList with the items to add to the Live list control Dim arrayItems As New ArrayList() arrayItems.Add("Alert") arrayItems.Add("Confirm") arrayItems.Add("Prompt") 'Set the data source to the ArrayList and bind it to the Live list control LiveList1.DataSource = arrayItems LiveList1.DataBind() End Sub Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveList1.SelectedIndexChanged 'When a type of MessageBox is selected from the list, show it Select Case (LiveList1.SelectedIndex) Case 0 LiveMessageBox1.Show("You have selected 'Alert'!", DialogType.Alert) Case 1 LiveMessageBox1.Show("You have selected 'Confirm'!", DialogType.Confirm) Case 2 LiveMessageBox1.Show("You have selected 'Prompt'!", DialogType.Prompt) Case Else End Select End Sub Private Sub LiveMessageBox1_Response(ByVal sender As Object, ByVal e As ResponseEventArgs) Handles LiveMessageBox1.Response 'After Confirm and Prompt MessageBoxes are shown, the Response event will fire 'If it is a Confirm box, indicate which button was pressed in a LiveTextBox If (e.DialogType = DialogType.Confirm) Then If (e.Confirmed) Then LiveTextBox1.Text = "The OK button was pressed!" Else LiveTextBox1.Text = "The Cancel button was pressed!" End If 'If it is a Prompt box, show the input data (or indicate the prompt was cancelled) in a LiveTextBox ElseIf (e.DialogType = DialogType.Prompt) Then If (Not e.Confirmed) Then LiveTextBox1.Text = "The Prompt was cancelled!" Else LiveTextBox1.Text = "The inputted data was: " + e.Text End If End If End Sub |
C# | Copy Code |
---|---|
//In this example, items are added to a Live List control using an ArrayList when a LiveButton is pressed //The items include different LiveMessageBox Dialog Types //When one of the Types is selected in the List, the MessageBox is shown //LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList private void LiveButton1_Click(object sender, System.EventArgs e) { //Create a new ArrayList with the items to add to the Live list control ArrayList arrayItems = new ArrayList(); arrayItems.Add("Alert"); arrayItems.Add("Confirm"); arrayItems.Add("Prompt"); //Set the data source to the ArrayList and bind it to the Live list control LiveList1.DataSource = arrayItems; LiveList1.DataBind(); } private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e) { //When a type of MessageBox is selected from the list, show it switch (LiveList1.SelectedIndex) { case 0: LiveMessageBox1.Show("You have selected 'Alert'!", DialogType.Alert); break; case 1: LiveMessageBox1.Show("You have selected 'Confirm'!", DialogType.Confirm); break; case 2: LiveMessageBox1.Show("You have selected 'Prompt'!", DialogType.Prompt); break; default: break; } } private void LiveMessageBox1_Response(object sender, ResponseEventArgs e) { //After Confirm and Prompt MessageBoxes are shown, the Response event will fire //If it is a Confirm box, indicate which button was pressed in a LiveTextBox if (e.DialogType == DialogType.Confirm) { if (e.Confirmed) LiveTextBox1.Text = "The OK button was pressed!"; else LiveTextBox1.Text = "The Cancel button was pressed!"; } //If it is a Prompt box, show the input data (or indicate the prompt was cancelled) in a LiveTextBox else if (e.DialogType == DialogType.Prompt) { if (!e.Confirmed) LiveTextBox1.Text = "The Prompt was cancelled!"; else LiveTextBox1.Text = "The inputted data was: " + e.Text; } } |
Use LiveMessageBox.Show to inform the user, ask the user for confirmation, or prompt the user for information.
A LiveMessageBox.Response event will fire after the user has responded to a DialogType.Confirm or DialogType.Prompt LiveMessageBox.
System.Object
System.Web.UI.Control
Dart.LiveControls.LiveMessageBox
Target Platforms: Microsoft .NET Framework 2.0