Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls

Partial Public Class Include_IncludePart
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
        'Apply server-side event
        AddHandler myInclude.DataBinding, AddressOf myInclude_DataBinding
        myInclude.DataBind()
    End Sub


    Private Sub myInclude_DataBinding(ByVal sender As Object, ByVal e As APNSoft.WebControls.IncludeEventArgs)
        'Get contents of included file
        Dim contents As String = e.Contents

        'Extract the MainDataDIV by using the HtmlAgilityPack
        Dim myHtmlDocument As New HtmlAgilityPack.HtmlDocument()
        myHtmlDocument.LoadHtml(contents)
        Dim MainDataDIV As String = myHtmlDocument.DocumentNode.SelectSingleNode("//div[@id='MainDataDIV']").InnerHtml

        'Set new contents
        e.Contents = MainDataDIV
    End Sub

End Class