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.");
}
}
Partager