HtmlWindow.Confirm(String) HtmlWindow.Confirm(String) HtmlWindow.Confirm(String) HtmlWindow.Confirm(String) Method


yes/no の応答を求めるメッセージとボタンを含むダイアログ ボックスを表示します。Displays a dialog box with a message and buttons to solicit a yes/no response.

 bool Confirm(System::String ^ message);
public bool Confirm (string message);
member this.Confirm : string -> bool
Public Function Confirm (message As String) As Boolean


String String String String

ユーザーに表示するテキスト。The text to display to the user.


ユーザーが [はい] をクリックした場合は true。ユーザーが [いいえ] をクリックしたか、ダイアログ ボックスを閉じた場合は falsetrue if the user clicked Yes; false if the user clicked No or closed the dialog box.

次の HTML をコピーして、orderForm.htm と呼ばれる形式に保存します。Copy the following HTML and save it into a form called orderForm.htm:

<FORM name="NewOrderForm">
Select Part Type:
<SELECT name="PartType">
Quantity: <INPUT type="text" name="PartQty" size="2" maxsize="2" /><br/>
<INPUT type="text" name="PartBuilding" size="2" maxsize="2"/> /  
<INPUT type="text" name="PartDesk" size="2" maxsize="2"/><p/>
<INPUT type="submit" value="Transmit Order"/>

次の例では、表示、 Confirm ダイアログ ボックスのユーザーが送信NewOrderFormします。The following example displays a Confirm dialog box when the user submits NewOrderForm.

HtmlWindow orderWindow;
HtmlElement formElement;

private void LoadOrderForm()
	if (!(webBrowser1.Document == null)) 
		HtmlDocument doc = webBrowser1.Document;
		orderWindow = doc.Window.OpenNew(new Uri("file://C:\\orderForm.htm"), "");

		//!TODO: Perform this in the load event handler!
		// Get order form. 
		HtmlElementCollection elemCollection = doc.All.GetElementsByName("NewOrderForm");
		if (elemCollection.Count == 1) 
			formElement = elemCollection[0];
			//!TODO: Awaiting DCR
			//formElement.AttachEventHandler("onsubmit", new HtmlElementEventHandler(Form_Submit));

private void Form_Submit(object sender, HtmlElementEventArgs e)
	bool doOrder = orderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?");
	if (!doOrder)
		//Cancel the submit. 
		e.ReturnValue = false;
		orderWindow.Alert("Submit cancelled.");
Dim OrderWindow As HtmlWindow
Dim FormElement As HtmlElement

Private Sub NewOrderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewOrderButton.Click
End Sub

Private Sub LoadOrderForm()
    If (WebBrowser1.Document IsNot Nothing) Then
        With WebBrowser1.Document
            OrderWindow = .Window.OpenNew(New Uri("file://C:\\orderForm.htm"), "")

            ' !TODO: Perform this in the load event handler!
            ' Get order form. 
            Dim ElemCollection As System.Windows.Forms.HtmlElementCollection = .All.GetElementsByName("NewOrderForm")
            If (ElemCollection.Count = 1) Then
                FormElement = ElemCollection(0)
                ' TODO: Resolve this. 
                'FormElement.AttachEventHandler("onsubmit", New HtmlElementEventHandler(AddressOf Form_Submit))
            End If
        End With

    End If
End Sub

Private Sub Form_Submit(ByVal sender As Object, ByVal e As HtmlElementEventArgs)
    Dim DoOrder As Boolean = OrderWindow.Confirm("Once you transmit this order, you cannot cancel it. Submit?")
    If (Not DoOrder) Then
        ' Cancel the submit. 
        e.ReturnValue = False
        OrderWindow.Alert("Submit cancelled.")
    End If
End Sub


Confirm モーダル ダイアログ ボックスを表示します。ユーザーは最初にこのダイアログ ボックスを閉じることがなく、基になる HTML ページにアクセスできません。Confirm displays a modal dialog box; the user will not be able to access the underlying HTML page without first closing this dialog box.