Using in an ASP.NET WebForm

Intgrating Morphfolia with “standard” ASP.NET pages is easy-peasy; let’s take a look…

Here’s (part of) the mark-up for a typical ASP.NET page:

<body>

  <asp:PlaceHolder ID="PageHeader" runat="server"></asp:PlaceHolder>

  <form id="form1" runat="server">

  <asp:PlaceHolder ID="PageContent" runat="server"></asp:PlaceHolder>

  </form>

  <asp:PlaceHolder ID="PageFooter" runat="server"></asp:PlaceHolder>

</body>

…And here is the code-behind:

protected void Page_Load(object sender, EventArgs e)
    {
        Morphfolia.PublishingSystem.WebFormHelper.LogRequest(System.Web.HttpContext.Current);
        Morphfolia.PublishingSystem.WebFormHelper webFormHelper = new Morphfolia.PublishingSystem.WebFormHelper();

        webFormHelper.AmendHTMLHead(Page);

        PageHeader.Controls.Add(webFormHelper.CreateHeader());
        PageContent.Controls.Add(webFormHelper.ContentForPage());
        PageFooter.Controls.Add(webFormHelper.CreateFooter());
    }

The PageHeader and PageFooter PlaceHolders will be where the skin gets embedded (bascially, its exactly the same way the HTTP Handler wraps it around the specificed PageLayout (WebControl) when Morphfolia serves content out normally).

The PageHeader is outside the FORM tag as the header (part of the skin) that I’m using has it’s own FORM tag.

Finally, the content for the page (as added by the user in the admin area) is piped into the PageContent PlaceHolder; this is done by adding a page as you would (through the admin area / CMS functionality) but then including the actual ASP.NET page/files and altering the config so that the URL is handled by the normal ASP.NET engine and not the Morphfolia HTTP Handler.

This is a simple example, and you can get far more complex if you want.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s