Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Templating

Status
Not open for further replies.

VBRookie

Programmer
May 29, 2001
331
US
I'm utilizing Paul Wilson's technique for page templating (
I'm creating a base page class and my other pages are inheritaged from it. The code looks as such (directly from his site):

protected override void OnInit(System.EventArgs e) {
this.Controls.AddAt(0, LoadControl("Header.ascx"));
base.OnInit(e);
this.Controls.Add(LoadControl("Footer.ascx"));
}

Here the header and footer controls are in place and my aspx will be inserted in the middle. My layout though is a little more complex than this example and I need to have a form tag encapsulating several user controls. I cannot start a form tag in one control and end it in another that causes an error.

Is there a way to open and close the form tags in the my base class? For Example:

protected override void OnInit(System.EventArgs e) {
this.Controls.AddAt(0, LoadControl("control1.ascx"));
// form start tag here
this.Controls.AddAt(1, LoadControl("control2.ascx"));
this.Controls.AddAt(2, LoadControl("control3.ascx"));
base.OnInit(e);
this.Controls.AddAt(3, LoadControl("control4.ascx"));
//form end tag here
this.Controls.Add(LoadControl("Footer.ascx"));
}

I asked Paul but I believe that he is on vacation right now and I have a very tight deadline. Does anyone know if this is doable and if so what is the syntax? I was trying to do it using HtmlTextWriter but to no avail. Thanks in advance!

- VBRookie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top