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
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