This project is read-only.

importing forms created in VS2005 into a page in blogengine

Feb 1, 2009 at 8:00 PM
I'm working in a group for a student project (last one before I graduate actually) and I'm being given web forms created in Visual Studio 2005 and my responsibility is to import them into a page in blogengine.  I'm having trouble along the way as I'm not incredibly experienced in .NET or C# and it seems the requirements for their forms/code are conflicting with how I'm trying to create these pages.  I've tried mirroring/copying the format of the default.aspx and contact.aspx pages for example, in that I've taken just the markup from my group's web form and put it in between <asp:Content ID="Content1" ContentPlaceHolderID="cphBody" Runat="Server">.  I've pointed to their code file and done everything else I can think of but I'm running into the error "Content controls are allowed only in content page that references a master page". 

Instead of focusing on this one error, which could be a simple solution none-the-less, does anyone have any helpful information on making sure I'm doing everything correctly in order to import these forms onto a blogengine page?  I can provide any of my files if needed.
Feb 1, 2009 at 8:02 PM
I suppose I should mention that I've gone the route of creating the .aspx page itself in the root directory as opposed to using Blogengine to create a "page" and importing the code there.  I didn't think you could do this since I wouldn't be able to import javascript needed or point to the code file and all that.  So when I tried copying the format of the existing .aspx pages in the directory (default, contact, archive, etc) I'm running in to errors.
Feb 1, 2009 at 11:06 PM
In a simple masterpage scenario, you have the <asp:Content> tag in the content page.  On the same content page, you also have a MasterPageFile attribute in the <%@ Page %> directive at the top ... like:

<%@ Page Language="C#" MasterPageFile="~/master1.master" AutoEventWireup="true" CodeFile="Default1.aspx.cs" Inherits="Default1" %>

It's required that a content page is a content page of some master page.  In BlogEngine's content pages, however, the MasterPageFile attribute is not there.  For example, the contact.aspx page looks like,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="contact.aspx.cs" Inherits="contact" ValidateRequest="false" %>

The reason the MasterPageFile attribute is not there is because the master page is being set dynamically at runtime.  Using the contact page as an example, you see in the line above that it inherits from the "contact" class in the contact.aspx.cs file.  If you then go into the contact.aspx.cs file, you'll see this line:

public partial class contact : BlogBasePage, ICallbackEventHandler

This contact page is inheriting the BlogBasePage which is a class in the BlogEngine core files that are compiled as a DLL in your BIN directory.  In that BlogBasePage file, it is dynamically setting the content page's master page to whatever the blog's theme is.

There's several ways to replicate this.  A very simple implementation of this is ...

===== file: test.aspx =====
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<asp:Content ID="Content1" ContentPlaceHolderID="cphBody" Runat="Server">
  testing ...

===== file: test.aspx.cs =====
using System;
using System.Collections;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;

public partial class test : BlogBasePage