---
title: "How to: Access the Managed HTML Document Object Model"
ms.date: "03/30/2017"
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "HTML DOM [Windows Forms], accessing"
- "managed HTML DOM [Windows Forms], accessing"
ms.assetid: 40fa5cd5-1ed8-42f6-a93f-9ac01608bbeb
---
# How to: Access the Managed HTML Document Object Model
You can access the managed HTML Document Object Model (DOM) from two types of applications:
- A Windows Forms application (.exe) that hosted the managed control. These two technologies complement one another, with the control displaying the page to the user and the HTML DOM representing the document's logical structure.
- A Windows Forms hosted within Internet Explorer. You can access the HTML DOM representing the page on which your is hosted in order to change the document's structure or open modal dialog boxes, among many other possibilities.
### To access DOM from a Windows Forms application
1. Host a control within your Windows Forms application and monitor for the event. For details on hosting controls and monitoring for events, see [Events](https://docs.microsoft.com/dotnet/standard/events/index).
2. Retrieve the for the current page by accessing the property of the control.
### To access DOM from a UserControl hosted in Internet Explorer
1. Create your own custom derived class of the class. For more information, see [How to: Author Composite Controls](how-to-author-composite-controls.md).
2. Place the following code inside of your Load event handler for your :
[!code-csharp[AccessHTMLDOMControl#1](~/samples/snippets/csharp/VS_Snippets_Winforms/AccessHTMLDOMControl/cs/UserControl1.cs#1)]
[!code-vb[AccessHTMLDOMControl#1](~/samples/snippets/visualbasic/VS_Snippets_Winforms/AccessHTMLDOMControl/vb/UserControl1.vb#1)]
## Robust Programming
1. When using the DOM through the control, you should always wait until the event occurs before attempting to access the property of the control. The event is raised after the entire document has loaded; if you use the DOM before then, you risk causing a run-time exception in your application.
## .NET Framework Security
1. Your application or will require full trust in order to access the managed HTML DOM. If you are deploying a Windows Forms application using ClickOnce, you can request full trust using either Permission Elevation or Trusted Application Deployment; see [Securing ClickOnce Applications](/visualstudio/deployment/securing-clickonce-applications) for details.
## See also
- [Using the Managed HTML Document Object Model](using-the-managed-html-document-object-model.md)