Wednesday, 11 September 2013

BasePage in ASP.Net

BasePage in ASP.Net

i want to create a base class page that has all the scripts, link, and
icon in it and i have this so far
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace VGD.Client
{
public class BasePage : Page
{
public new string Title { get; set; }
protected override void FrameworkInitialize()
{
Controls.Add(ParseControl("<!DOCTYPE html>"));
Controls.Add(ParseControl("<html lang='en'>"));
Controls.Add(ParseControl(head()));
Controls.Add(ParseControl(upperBody()));
base.FrameworkInitialize();
}
protected override void OnPreRender(EventArgs e)
{
Controls.Add(ParseControl(lowerBody()));
base.OnPreRender(e);
}
private string head()
{
string _retVal = @"<head id='Head1' runat='server'>
<title>" + Title + @"</title>
</head>";
return _retVal;
}
private string upperBody()
{
string _retVal = @"<body>
<form runat='server'>";
return _retVal;
}
private string lowerBody()
{
string _retVal = @"</form>
</body>
</html>";
return _retVal;
}
}
}
but upon the initialize, it throws an error that Unexpected end of file
looking for </form> tag.
i separated the upperBody() and lowerBody() so that the content of
Home.aspx will be added in between the upperBody() and lowerBody() upon
creating the page.
any help please.

No comments:

Post a Comment