using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Include_IncludePart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Apply server-side event
        myInclude.DataBinding += new APNSoft.WebControls.IncludeEventHandler(myInclude_DataBinding);
        myInclude.DataBind();
    }


    void myInclude_DataBinding(object sender, APNSoft.WebControls.IncludeEventArgs e)
    {
        //Get contents of included file
        string contents = e.Contents;

        //Extract the MainDataDIV by using the HtmlAgilityPack
        HtmlAgilityPack.HtmlDocument myHtmlDocument = new HtmlAgilityPack.HtmlDocument();
        myHtmlDocument.LoadHtml(contents);
        string MainDataDIV = myHtmlDocument.DocumentNode.SelectSingleNode("//div[@id='MainDataDIV']").InnerHtml;

        //Set new contents
        e.Contents = MainDataDIV;
    }

}