Class ConfirmEvent

Displays a client side confirmation dialog a client event

Inheritance
System.Object
ConfirmEvent
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.ClientScript.Events
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public class ConfirmEvent : EventBase
Examples

Create a client side post confirmation event handler which takes an event argument and the confirmation result as parameters.

<script type="text/javascript">
function postConfirm(e, confirmResult){
    if (confirmResult==true)
        alert("The user confirmed");
}
<script>

Create a confirm event in C# with confirm condition which will be run before the confirmation dialog is shown and a post confirm function reference run once the user has either pressed "OK" or "Cancel" in the confirmation dialog.

ConfirmEvent confirmEvent = new ConfirmEvent(EventType.Click, 
    "Do you really want to delete this item?", 
    "document.getElementById('myCheckbox').checked == true", "postConfirm")

ScriptManager.AddEventListener(myControl, confirmEvent);

Constructors

ConfirmEvent(EventType)

Create a new Confirmation dialog event

Declaration
public ConfirmEvent(EventType eventType)
Parameters
Type Name Description
EventType eventType

The client side event to show the confirmation dialog for

ConfirmEvent(EventType, String)

Create a new Confirmation dialog event

Declaration
public ConfirmEvent(EventType eventType, string confirmMessage)
Parameters
Type Name Description
EventType eventType

The client side event to show the confirmation dialog for

System.String confirmMessage

Confirmation message shown in the confirmation dialog

ConfirmEvent(EventType, String, String)

Create a new Confirmation dialog event

Declaration
public ConfirmEvent(EventType eventType, string confirmMessage, string confirmCondition)
Parameters
Type Name Description
EventType eventType

The client side event to show the confirmation dialog for

System.String confirmMessage

Confirmation message shown in the confirmation dialog

System.String confirmCondition

Client script conditional statement used to decide whether the confirmation dialog is shown.

ConfirmEvent(EventType, String, String, String)

Create a new Confirmation dialog event

Declaration
public ConfirmEvent(EventType eventType, string confirmMessage, string confirmCondition, string postConfirmHandler)
Parameters
Type Name Description
EventType eventType

The client side event to show the confirmation dialog for

System.String confirmMessage

Confirmation message shown in the confirmation dialog

System.String confirmCondition

Client script conditional statement used to decide whether the confirmation dialog is shown.

System.String postConfirmHandler

The name of a client script function or an inluine function to be executed after the confirmation dialog is dismissed.

Properties

ConfirmCondition

Client script conditional statement used to decide whether the confirmation dialog is shown.

Declaration
public string ConfirmCondition { get; set; }
Property Value
Type Description
System.String

Returns System.String.Empty if undefined or set to null.

Remarks

If the statement evaluates to true the confirmation dialog is shown otherwise the dialog will be supressed.

Examples
    confirmEvent.ConfirmCondition = "document.getElementById('myCheckbox').checked == true";

ConfirmMessage

Confirmation message shown in the confirmation dialog

Declaration
public string ConfirmMessage { get; set; }
Property Value
Type Description
System.String

Returns System.String.Empty if undefined or set to null.

Remarks

Client script escape characters will be escaped before the string is emitted to the client.

PostConfirmHandler

A client script method to run after the user has either clicked the confirmation dialog.

Declaration
public string PostConfirmHandler { get; set; }
Property Value
Type Description
System.String

Returns System.String.Empty if undefined or set to null.

Remarks

The method will be called in the same context as the confirmation dialog, thus the "this" object will refer to the element that triggered the event. The method signature should be

function postConfirmFunction(e, confirmResult) 
{
    // Code...
}

where "e" is the event object and "confirmtResult" is the confirmation result.

Methods

AttachEvent(ScriptManager, String)

Attaches the confirmation dialog event to the supplied script manager

Declaration
public override void AttachEvent(ScriptManager scriptManager, string clientId)
Parameters
Type Name Description
ScriptManager scriptManager
System.String clientId
Overrides

Extension Methods