PowerWEB LiveControls for ASP.NET
Show Method
See Also  Example Send comments on this topic.
Dart.LiveControls Namespace > LiveMessageBox Class : Show Method



text
The text to show in the message box.
dialogType
The type of JavaScript message box to show.
Shows a JavaScript message box.

Syntax

Visual Basic (Declaration) 
Public Sub Show( _
   ByVal text As String, _
   ByVal dialogType As DialogType _
) 
Visual Basic (Usage)Copy Code
Dim instance As LiveMessageBox
Dim text As String
Dim dialogType As DialogType
 
instance.Show(text, dialogType)
C# 
public void Show( 
   string text,
   DialogType dialogType
)
C++/CLI 
public:
void Show( 
   String^ text,
   DialogType dialogType
) 

Parameters

text
The text to show in the message box.
dialogType
The type of JavaScript message box to show.

Example

The following example demonstrates using a LiveMessageBox in combination with a Live List control.
Visual BasicCopy 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;	
	}
}

Remarks

Shows one of three JavaScript message boxes, as specified by the DialogType parameter.

The options are Alert, Confirm and Prompt. For Confirm and Prompt types, a Response event will fire when the response is returned.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

Documentation Version 4.0.2
© 2012 Dart Communications. All Rights Reserved.