Table of Contents

Class HTMLDialogElement

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The HTMLDialogElement interface provides methods to manipulate {{HTMLElement("dialog")}} elements. It inherits properties and methods from the HTMLElement interface.

[Value("HTMLDialogElement")]
public class HTMLDialogElement : HTMLElement
Inheritance
HTMLDialogElement
Inherited Members

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN

Constructors

HTMLDialogElement()

public HTMLDialogElement()

Properties

ClosedBy

The closedBy property of the
HTMLDialogElement interface indicates the types of user actions that can be used to close the associated {{htmlelement("dialog")}} element. It sets or returns the dialog's closedby attribute value.

[Value("closedBy")]
public string ClosedBy { get; set; }

Property Value

string

A string; possible values are:

Remarks

Open

The open property of the
HTMLDialogElement interface is a boolean value reflecting the
open HTML attribute, indicating whether the dialog is
available for interaction.

[Value("open")]
public bool Open { get; set; }

Property Value

bool

A boolean value representing the state of the open HTML attribute. A value of true means that the dialog is showing, while false means it's not showing.

WARNING
While the open property is technically not read-only and can be set directly, doing so is strongly discouraged by the HTML specification, as it can break normal dialog interactions in unexpected ways. For example, the close event won't fire when programmatically setting open to false, and subsequent calls to the close() and requestClose() methods will have no effect. Instead, it's better to use methods such as show(), showModal(), close(), and requestClose() to change the value of the open attribute.

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN

ReturnValue

The returnValue property of the HTMLDialogElement interface is a string representing the return value for a {{htmlelement("dialog")}} element when it's closed.
You can set the value directly (dialog.returnValue = "result") or by providing the value as a string argument to Close(string) or RequestClose(string).

[Value("returnValue")]
public string ReturnValue { get; set; }

Property Value

string

A string representing the returnValue of the dialog.
Defaults to an empty string ("").

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN

Methods

Close(string)

The close() method of the HTMLDialogElement interface closes the {{htmlelement("dialog")}}.
An optional string may be passed as an argument, updating the returnValue of the dialog.

[Value("close")]
public GlobalObject.Undefined Close(string returnValue = null)

Parameters

returnValue string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN

RequestClose(string)

The requestClose() method of the HTMLDialogElement interface requests to close the {{htmlelement("dialog")}}.
An optional string may be passed as an argument, updating the returnValue of the dialog.

[Value("requestClose")]
public GlobalObject.Undefined RequestClose(string returnValue = null)

Parameters

returnValue string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

This method differs from the Close(string) method in that it fires a HTMLDialogElement.Cancel event before firing the Close(string) event.
Authors can call PreventDefault() in the handler for the cancel event to prevent the dialog from closing.

This method exposes the same behavior as the dialog's internal close watcher.

-The HTML element implementing this interface: dialog.

See also on MDN

Show()

The show() method of the HTMLDialogElement
interface displays the dialog modelessly, i.e., still allowing interaction with content
outside of the dialog.

[Value("show")]
public GlobalObject.Undefined Show()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN

ShowModal()

The showModal() method of the
HTMLDialogElement interface displays the dialog as a modal, over the top
of any other dialogs that might be present. It displays in the top layer, along with a
{{cssxref('::backdrop')}} pseudo-element. Elements inside the same document as the dialog, except the dialog and its descendants, become inert (as if the inert attribute is specified). Only the containing document becomes blocked; if the dialog is rendered inside an iframe, the rest of the page remains interactive.

[Value("showModal")]
public GlobalObject.Undefined ShowModal()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

-The HTML element implementing this interface: dialog.

See also on MDN