473,756 Members | 6,028 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Header/Footer Block Control Idea, but not Templated Control

I keep running into this over and over again...
I want a block server control that renders a header and footer, and child
controls in between.
But I don't want a templated control, for the following reasons:

1) Render blocks are not allowed inside a templated control.
2) I want the inner controls scoped at the parent aspx (or ascx), not at the
template naming container.

This type of control would be ideal for website headers and footers, or
something like a control that simulates a windows tab control with tabs at
the top with a table border around the contents.

For example, for headers and footers, I do this alot:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header " Src="Header.asc x" %>
<%@ Register TagPrefix="MySt uff" TagName="Footer " Src="Footer.asc x" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Head er runat="server" />
This is a page
Sum: <%= Total %>
<p>
Add This Many: <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
<MyStuff:Foot er runat="server" />
</form>
</body>
</html>

Code behind:

public class DumbCalculatorP age : Page {
public int Total {
get {
if(ViewState["Total"] == null) {
ViewState["Total"] = 0;
}
return((int) ViewState["Total"]);
}
set {
ViewState["Total"] = value;
}
}

protected void DoSomething(obj ect sender, EventArgs e) {
Total += int.Parse(MyTex tBox.Text);
}

protected TextBox MyTextBox;
}

Now, wouldn't it be great to be able to change that aspx page to this, and
still have it compile and work with the same code behind class:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header Footer"
Src="HeaderFoot er.astx" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Header Footer runat="server">
Sum: <%= Total %>
<p>
Add This : <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
</MyStuff:HeaderF ooter>
</form>
</body>
</html>

You'll noticed that I've invented a new extension: "astx" T for template (I
can't think of a better name, sorry).
What does an astx look like? very similar to ascx with a couple new tags:

<%@ TemplateControl ... %>

<table>
<tr>
<td>Header top</td>
</tr>
<tr>
<td>
<%@ ParentScope %>
</td>
</tr>
<tr>
<td>Footer row</td>
</tr>
</table>

How would this work? Well the TemplateControl would need two controls
collections, HeaderControls and FooterControls. And two Render methods
RenderHeader and RenderFooter. (The inner controls defined on the page
belong to the parent! It doesn't need to reference them.) During the
render phase of the page, the page would have to call RenderHeader, then
render the inner controls where the ParentScope tag is, then RenderFooter.

Now if you are talking about a static header and footer like my example, it
seems like alot of extra work to change the framework to support this. But
imagine a more complex control, like a tab control that has tabs and that is
rendered as a table around it's contents. Then add properties to the tab
control. Add a property of tab alignment: TabAlignment="T op" versus
TabAlignment="B ottom" or TabAlignment="R ight". Then add data binding to the
tab control to determine what tabs to show, and events for clicking on the
tab links. Now the header and footer are very closely tied together, and do
some neat stuff. The idea of this kind of Template becomes much more
interesting.

Implementing this as a templated control we loose our render blocks and
scoping. Why should the page have to search the template control for it's
inner text box? Why can't I use that simple render block?
Implementing this as two separate controls, we loose the connection between
header and footer. It's tough to find out where our td/tr/table mismatches
are between header and footer in different controls. Properties for the
header and footer aren't tied together in any way if they affect the
rendering.

Have I gone insane? Or is this a good idea? Or is there a similar way to
do this already that I am overlooking that does what I want? Is there a
reason this wouldn't work? (Seems the control hierarchy would be a bit odd
:)

I just keep running into this and I want a better solution than the current
template control implementation.
Nov 18 '05 #1
3 1944
If your target browsers are uplevel, what about using absolute positioning
instead? Then you can just have everything in the header, including a div
called Footer which is positioned to be at the bottom of the page ...

Justin

"John Crowley" <ax*****@hotmai l.com> wrote in message
news:av******** *************** @twister.southe ast.rr.com...
I keep running into this over and over again...
I want a block server control that renders a header and footer, and child
controls in between.
But I don't want a templated control, for the following reasons:

1) Render blocks are not allowed inside a templated control.
2) I want the inner controls scoped at the parent aspx (or ascx), not at the template naming container.

This type of control would be ideal for website headers and footers, or
something like a control that simulates a windows tab control with tabs at
the top with a table border around the contents.

For example, for headers and footers, I do this alot:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header " Src="Header.asc x" %>
<%@ Register TagPrefix="MySt uff" TagName="Footer " Src="Footer.asc x" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Head er runat="server" />
This is a page
Sum: <%= Total %>
<p>
Add This Many: <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
<MyStuff:Foot er runat="server" />
</form>
</body>
</html>

Code behind:

public class DumbCalculatorP age : Page {
public int Total {
get {
if(ViewState["Total"] == null) {
ViewState["Total"] = 0;
}
return((int) ViewState["Total"]);
}
set {
ViewState["Total"] = value;
}
}

protected void DoSomething(obj ect sender, EventArgs e) {
Total += int.Parse(MyTex tBox.Text);
}

protected TextBox MyTextBox;
}

Now, wouldn't it be great to be able to change that aspx page to this, and
still have it compile and work with the same code behind class:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header Footer"
Src="HeaderFoot er.astx" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Header Footer runat="server">
Sum: <%= Total %>
<p>
Add This : <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
</MyStuff:HeaderF ooter>
</form>
</body>
</html>

You'll noticed that I've invented a new extension: "astx" T for template (I can't think of a better name, sorry).
What does an astx look like? very similar to ascx with a couple new tags:

<%@ TemplateControl ... %>

<table>
<tr>
<td>Header top</td>
</tr>
<tr>
<td>
<%@ ParentScope %>
</td>
</tr>
<tr>
<td>Footer row</td>
</tr>
</table>

How would this work? Well the TemplateControl would need two controls
collections, HeaderControls and FooterControls. And two Render methods
RenderHeader and RenderFooter. (The inner controls defined on the page
belong to the parent! It doesn't need to reference them.) During the
render phase of the page, the page would have to call RenderHeader, then
render the inner controls where the ParentScope tag is, then RenderFooter.

Now if you are talking about a static header and footer like my example, it seems like alot of extra work to change the framework to support this. But imagine a more complex control, like a tab control that has tabs and that is rendered as a table around it's contents. Then add properties to the tab
control. Add a property of tab alignment: TabAlignment="T op" versus
TabAlignment="B ottom" or TabAlignment="R ight". Then add data binding to the tab control to determine what tabs to show, and events for clicking on the
tab links. Now the header and footer are very closely tied together, and do some neat stuff. The idea of this kind of Template becomes much more
interesting.

Implementing this as a templated control we loose our render blocks and
scoping. Why should the page have to search the template control for it's
inner text box? Why can't I use that simple render block?
Implementing this as two separate controls, we loose the connection between header and footer. It's tough to find out where our td/tr/table mismatches are between header and footer in different controls. Properties for the
header and footer aren't tied together in any way if they affect the
rendering.

Have I gone insane? Or is this a good idea? Or is there a similar way to
do this already that I am overlooking that does what I want? Is there a
reason this wouldn't work? (Seems the control hierarchy would be a bit odd :)

I just keep running into this and I want a better solution than the current template control implementation.

Nov 18 '05 #2
If your target browsers are uplevel, what about using absolute positioning
instead? Then you can just have everything in the header, including a div
called Footer which is positioned to be at the bottom of the page ...

Justin

"John Crowley" <ax*****@hotmai l.com> wrote in message
news:av******** *************** @twister.southe ast.rr.com...
I keep running into this over and over again...
I want a block server control that renders a header and footer, and child
controls in between.
But I don't want a templated control, for the following reasons:

1) Render blocks are not allowed inside a templated control.
2) I want the inner controls scoped at the parent aspx (or ascx), not at the template naming container.

This type of control would be ideal for website headers and footers, or
something like a control that simulates a windows tab control with tabs at
the top with a table border around the contents.

For example, for headers and footers, I do this alot:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header " Src="Header.asc x" %>
<%@ Register TagPrefix="MySt uff" TagName="Footer " Src="Footer.asc x" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Head er runat="server" />
This is a page
Sum: <%= Total %>
<p>
Add This Many: <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
<MyStuff:Foot er runat="server" />
</form>
</body>
</html>

Code behind:

public class DumbCalculatorP age : Page {
public int Total {
get {
if(ViewState["Total"] == null) {
ViewState["Total"] = 0;
}
return((int) ViewState["Total"]);
}
set {
ViewState["Total"] = value;
}
}

protected void DoSomething(obj ect sender, EventArgs e) {
Total += int.Parse(MyTex tBox.Text);
}

protected TextBox MyTextBox;
}

Now, wouldn't it be great to be able to change that aspx page to this, and
still have it compile and work with the same code behind class:

<%@ Page Inherits="DumbC alculatorPage" %>
<%@ Register TagPrefix="MySt uff" TagName="Header Footer"
Src="HeaderFoot er.astx" %>

<html>
<head>
<title>Stupid Dumb Calculator</title>
</head>
<body>
<form runat="server">
<MyStuff:Header Footer runat="server">
Sum: <%= Total %>
<p>
Add This : <asp:TextBox id="MyTextBox" runat="server" />
<asp:Button OnClick="DoSome thing" Text="Go" runat="server" />
</MyStuff:HeaderF ooter>
</form>
</body>
</html>

You'll noticed that I've invented a new extension: "astx" T for template (I can't think of a better name, sorry).
What does an astx look like? very similar to ascx with a couple new tags:

<%@ TemplateControl ... %>

<table>
<tr>
<td>Header top</td>
</tr>
<tr>
<td>
<%@ ParentScope %>
</td>
</tr>
<tr>
<td>Footer row</td>
</tr>
</table>

How would this work? Well the TemplateControl would need two controls
collections, HeaderControls and FooterControls. And two Render methods
RenderHeader and RenderFooter. (The inner controls defined on the page
belong to the parent! It doesn't need to reference them.) During the
render phase of the page, the page would have to call RenderHeader, then
render the inner controls where the ParentScope tag is, then RenderFooter.

Now if you are talking about a static header and footer like my example, it seems like alot of extra work to change the framework to support this. But imagine a more complex control, like a tab control that has tabs and that is rendered as a table around it's contents. Then add properties to the tab
control. Add a property of tab alignment: TabAlignment="T op" versus
TabAlignment="B ottom" or TabAlignment="R ight". Then add data binding to the tab control to determine what tabs to show, and events for clicking on the
tab links. Now the header and footer are very closely tied together, and do some neat stuff. The idea of this kind of Template becomes much more
interesting.

Implementing this as a templated control we loose our render blocks and
scoping. Why should the page have to search the template control for it's
inner text box? Why can't I use that simple render block?
Implementing this as two separate controls, we loose the connection between header and footer. It's tough to find out where our td/tr/table mismatches are between header and footer in different controls. Properties for the
header and footer aren't tied together in any way if they affect the
rendering.

Have I gone insane? Or is this a good idea? Or is there a similar way to
do this already that I am overlooking that does what I want? Is there a
reason this wouldn't work? (Seems the control hierarchy would be a bit odd :)

I just keep running into this and I want a better solution than the current template control implementation.

Nov 18 '05 #3
So shortly after I wrote this piece of garbage, I noticed that the PlaceHolder control does almost exactly what I want, except it doesn't render anything itself. It seems that a control that renders it's own content wouldn't be that much harder to do

It seems that the PlaceHolder control has a PlaceHolderCont rolBuilder class in the framework it's using to parse it's content. Anyone have any ideas on how it does what it does? The control builders seem to be less than well documented :)
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
4126
by: Jez | last post by:
I'm ashamed that I need to ask this question. I've been using PHP for almost a year now, and have used HTML extensively in the last few years. Often, when I create a new site, I use include() to add an HTML header at the top of the page and a footer (ususally including a menu) at the bottom. Up to now I've created two or more copies of each header and footer, the only difference being the path to linked files. For example, in
2
5056
by: Salad | last post by:
Is there a way to determine which section of a form a control is located in code....besides using the tag property?
0
357
by: John Crowley | last post by:
I keep running into this over and over again... I want a block server control that renders a header and footer, and child controls in between. But I don't want a templated control, for the following reasons: 1) Render blocks are not allowed inside a templated control. 2) I want the inner controls scoped at the parent aspx (or ascx), not at the template naming container. This type of control would be ideal for website headers and...
2
1624
by: Nicholas | last post by:
Here is the issue: 1. I would like to create an ASP.Net/C# control to append a dynamic header and footer to **every** web page (depending on the page the content of each will vary). I can easily create the control yet herein lay the problem: 2. The folks who edit the HTML content are NOT programmers and even though the content pages will have an aspx extension, there will be
0
1072
by: 00_ChInkPoIntD12 | last post by:
Is there any box wrapping control? so that I can put stuff in the box so that it looks more professional in a page. I am not sure what they call. It seems stupid to me to use "Header" and "Footer" (User Control) like this.. <c1:HEADER id="BoxHeader" runat="server"></c1:HEADER> ...Form, HTML Content or another control...
3
8132
by: Dabbler | last post by:
is there a way to show the header even when GridView is empty? the page looks kind of bare with just empydatatext or emptyrowtemplate. Thanks.
7
8729
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
0
1145
by: Matthias | last post by:
Hi all, I have a problem with XSL FO. I wrote a handbook for my application in XML and formats it with xsl:fo (FOP) for PDF output. The handbook has some chapters. I have to write the actual chapter heading (e.g. Handbook - Chapter 1 HEADING_OF_CHAPTER_ONE) into the header or footer to follow our styleguide. I use a template for the header like: <xsl:template name="Header"> <fo:table table-layout="fixed">
2
1689
by: ~john | last post by:
I'm trying to get my header to have 2 images, one for the top left and one for the top right. Here's a link to my page... http://levelwave.com/dev/div/index.html and will eventually be images but what I'm wanting is for the to be aligned left and to be aligned right. As of now they're both squished to the left and I'm not sure how to change my CSS to do this.
6
11541
by: G | last post by:
Hello Friend, I am newly migrated from ASP to ASP.NET. When i am using ASP i used have a folder with named includes where i store header. asp and footer.asp pages. and i use <!-- #include file ="'' --to access those files where ever in need. SO now my doubt is how to use the same thing(header & footer parts) in
0
9431
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9844
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7226
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5119
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5289
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.