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



Occurs when a response is returned from a LiveMessageBox of type DialogType.Prompt or DialogType.Confirm.

Syntax

Visual Basic (Declaration) 
<CategoryAttribute("Completion")>
<DescriptionAttribute("Raised when a response is returned when using DialogType.Prompt or DialogType.Confirm.")>
Public Event Response As ResponseEventHandler
Visual Basic (Usage)Copy Code
Dim instance As LiveMessageBox
Dim handler As ResponseEventHandler
 
AddHandler instance.Response, handler
C# 
[CategoryAttribute("Completion")]
[DescriptionAttribute("Raised when a response is returned when using DialogType.Prompt or DialogType.Confirm.")]
public event ResponseEventHandler Response
C++/CLI 
[CategoryAttribute("Completion")]
[DescriptionAttribute("Raised when a response is returned when using DialogType.Prompt or DialogType.Confirm.")]
public:
event ResponseEventHandler^ Response

Event Data

The event handler receives an argument of type ResponseEventArgs containing data related to this event. The following ResponseEventArgs properties provide information specific to this event.

PropertyDescription
Confirmed Gets or sets the confirmed state of a LiveMessageBox.
DialogType Gets or sets the confirmed state of a LiveMessageBox.
Text Gets or sets the response message of a LiveMessageBox.

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

The Response event fires when a response is returned from a LiveMessageBox of type DialogType.Prompt or DialogType.Confirm.

Requirements

Target Platforms: Microsoft .NET Framework 2.0

See Also

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