By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,496 Members | 1,527 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,496 IT Pros & Developers. It's quick & easy.

ASP.NET V1.1 Headers and footers help

P: n/a
Hey,
this is probbly a really simple answer, but im useing ASP.NET V1.1 and
im trying to create a dynamic header, but a static footer. But i dont
want to use place holders. thou its probbly the best way.

What i am doing is useing Response.write, so heres a example

Function.vb
---------------------------------------------------------------------------
---------------
Public Function Header(strTitle as string, bolUserLoggedIn as Boolean)
as string
Header = ("<html><head><title>" & strTitle & "</title></head><body>")
If bolUserLoggedIn = True Then
Header += ("Welcome: " & strUser & "<br> <a
href='/logout.aspx'>LogOut</a>")
Else
Header += ("Welcome, Please <ahref='/login.aspx'>log in</a>")
end if
End Function

Public Function Footer() as String
Footer = ("Created By: <br> </body> </html>")
End Function

index.aspx.vb
---------------------------------------------------------------------------
-------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write(Header("Test Page",UserLoggedIn))

Response.Write(Footer)
End Sub

index.aspx (Just got a button on at the moment that dont do anything)
---------------------------------------------------------------------------
----------------
<form runat="server" ID="Form1">
<asp:button id="Test" runat="server" Text="Test"></asp:button>
</form>

That is what i am doing, but as the page is loading, it is putting the
header and footer, then the body. So is there anyway that i can have it

going Header Body Footer. Thou liek i said i dont really want to use
palce holders. but also i dont want to ahve to write the whole of hte
body out for each page, in response.write

So whats the best method of creating headers and footers. i have read
so many different ways, and quite a few ways of useing Placeholders,
but it has jsut confused me.

Also another reason i have used response,write for the header is
because of the title, so you might be in the same page, but the title
will change for the users.

Also i would like to be able to use response.write for other things in
the web page, but without them being placed at the top of the page, but

below the header.

I cant use ASp.NET V1.1 else i would just use a masterpage, its got to
be Version 1.1 sorry.

Regards, and Thank You In Advance
Chris

Jun 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
if you override the page onrender event you can manage this

override void OnRender(HtmlTextWriter out)
{
Response.Write(Header("Test Page",UserLoggedIn));
base.OnRender(out); // render page controls
Response.Write(Footer() );
}

-- bruce (sqlwork.com)

"Dessip" <De****@gmail.com> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com...
Hey,
this is probbly a really simple answer, but im useing ASP.NET V1.1 and
im trying to create a dynamic header, but a static footer. But i dont
want to use place holders. thou its probbly the best way.

What i am doing is useing Response.write, so heres a example

Function.vb
---------------------------------------------------------------------------
---------------
Public Function Header(strTitle as string, bolUserLoggedIn as Boolean)
as string
Header = ("<html><head><title>" & strTitle & "</title></head><body>")
If bolUserLoggedIn = True Then
Header += ("Welcome: " & strUser & "<br> <a
href='/logout.aspx'>LogOut</a>")
Else
Header += ("Welcome, Please <ahref='/login.aspx'>log in</a>")
end if
End Function

Public Function Footer() as String
Footer = ("Created By: <br> </body> </html>")
End Function

index.aspx.vb
---------------------------------------------------------------------------
-------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write(Header("Test Page",UserLoggedIn))

Response.Write(Footer)
End Sub

index.aspx (Just got a button on at the moment that dont do anything)
---------------------------------------------------------------------------
----------------
<form runat="server" ID="Form1">
<asp:button id="Test" runat="server" Text="Test"></asp:button>
</form>

That is what i am doing, but as the page is loading, it is putting the
header and footer, then the body. So is there anyway that i can have it

going Header Body Footer. Thou liek i said i dont really want to use
palce holders. but also i dont want to ahve to write the whole of hte
body out for each page, in response.write

So whats the best method of creating headers and footers. i have read
so many different ways, and quite a few ways of useing Placeholders,
but it has jsut confused me.

Also another reason i have used response,write for the header is
because of the title, so you might be in the same page, but the title
will change for the users.

Also i would like to be able to use response.write for other things in
the web page, but without them being placed at the top of the page, but

below the header.

I cant use ASp.NET V1.1 else i would just use a masterpage, its got to
be Version 1.1 sorry.

Regards, and Thank You In Advance
Chris

Jun 16 '06 #2

P: n/a
Hey,

That is excellent thank you. That is deffonatly going to make my life
ALOT easier.

Chris

bruce barker (sqlwork.com) wrote:
if you override the page onrender event you can manage this

override void OnRender(HtmlTextWriter out)
{
Response.Write(Header("Test Page",UserLoggedIn));
base.OnRender(out); // render page controls
Response.Write(Footer() );
}

-- bruce (sqlwork.com)

"Dessip" <De****@gmail.com> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com...
Hey,
this is probbly a really simple answer, but im useing ASP.NET V1.1 and
im trying to create a dynamic header, but a static footer. But i dont
want to use place holders. thou its probbly the best way.

What i am doing is useing Response.write, so heres a example

Function.vb
---------------------------------------------------------------------------
---------------
Public Function Header(strTitle as string, bolUserLoggedIn as Boolean)
as string
Header = ("<html><head><title>" & strTitle & "</title></head><body>")
If bolUserLoggedIn = True Then
Header += ("Welcome: " & strUser & "<br> <a
href='/logout.aspx'>LogOut</a>")
Else
Header += ("Welcome, Please <ahref='/login.aspx'>log in</a>")
end if
End Function

Public Function Footer() as String
Footer = ("Created By: <br> </body> </html>")
End Function

index.aspx.vb
---------------------------------------------------------------------------
-------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write(Header("Test Page",UserLoggedIn))

Response.Write(Footer)
End Sub

index.aspx (Just got a button on at the moment that dont do anything)
---------------------------------------------------------------------------
----------------
<form runat="server" ID="Form1">
<asp:button id="Test" runat="server" Text="Test"></asp:button>
</form>

That is what i am doing, but as the page is loading, it is putting the
header and footer, then the body. So is there anyway that i can have it

going Header Body Footer. Thou liek i said i dont really want to use
palce holders. but also i dont want to ahve to write the whole of hte
body out for each page, in response.write

So whats the best method of creating headers and footers. i have read
so many different ways, and quite a few ways of useing Placeholders,
but it has jsut confused me.

Also another reason i have used response,write for the header is
because of the title, so you might be in the same page, but the title
will change for the users.

Also i would like to be able to use response.write for other things in
the web page, but without them being placed at the top of the page, but

below the header.

I cant use ASp.NET V1.1 else i would just use a masterpage, its got to
be Version 1.1 sorry.

Regards, and Thank You In Advance
Chris


Jun 17 '06 #3

P: n/a
ok so im still having problems with that, i have looked for a few days
now, and still not getting anything. I changed the code to VB.Net
because thats the defualt language im doing it in, and here is what i
have got

defualt.aspx
----------------------------------
Protected Overrides Sub Render(ByVal writer As
System.Web.UI.HtmlTextWriter)
Dim pTracker As ProTracker = New ProTracker
writer.Write(pTracker.Header("Main Page",
Page.User.Identity.Name))
MyBase.Render(writer)
writer.Write(pTracker.Footer)
End Sub

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write("TEST")
End Sub
-----------------------------------
So i thought that, when that ran it would have put test in the middle
of the header and footer like this:

HEADER
----------------
TEST
---------------------
FOOTER

Where as its still doing it like this:

TEST
---------------------
HEADER
---------------------
FOOTER

Am i doing something wrong, just that i would have thought that because
i have override the structre, it would now load the header, then any
code i have got in the code behind, and HTML code, and then added the
footer.

Regards
Chris
bruce barker (sqlwork.com) wrote:
if you override the page onrender event you can manage this

override void OnRender(HtmlTextWriter out)
{
Response.Write(Header("Test Page",UserLoggedIn));
base.OnRender(out); // render page controls
Response.Write(Footer() );
}

-- bruce (sqlwork.com)

"Dessip" <De****@gmail.com> wrote in message
news:11*********************@r2g2000cwb.googlegrou ps.com...
Hey,
this is probbly a really simple answer, but im useing ASP.NET V1.1 and
im trying to create a dynamic header, but a static footer. But i dont
want to use place holders. thou its probbly the best way.

What i am doing is useing Response.write, so heres a example

Function.vb
---------------------------------------------------------------------------
---------------
Public Function Header(strTitle as string, bolUserLoggedIn as Boolean)
as string
Header = ("<html><head><title>" & strTitle & "</title></head><body>")
If bolUserLoggedIn = True Then
Header += ("Welcome: " & strUser & "<br> <a
href='/logout.aspx'>LogOut</a>")
Else
Header += ("Welcome, Please <ahref='/login.aspx'>log in</a>")
end if
End Function

Public Function Footer() as String
Footer = ("Created By: <br> </body> </html>")
End Function

index.aspx.vb
---------------------------------------------------------------------------
-------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Response.Write(Header("Test Page",UserLoggedIn))

Response.Write(Footer)
End Sub

index.aspx (Just got a button on at the moment that dont do anything)
---------------------------------------------------------------------------
----------------
<form runat="server" ID="Form1">
<asp:button id="Test" runat="server" Text="Test"></asp:button>
</form>

That is what i am doing, but as the page is loading, it is putting the
header and footer, then the body. So is there anyway that i can have it

going Header Body Footer. Thou liek i said i dont really want to use
palce holders. but also i dont want to ahve to write the whole of hte
body out for each page, in response.write

So whats the best method of creating headers and footers. i have read
so many different ways, and quite a few ways of useing Placeholders,
but it has jsut confused me.

Also another reason i have used response,write for the header is
because of the title, so you might be in the same page, but the title
will change for the users.

Also i would like to be able to use response.write for other things in
the web page, but without them being placed at the top of the page, but

below the header.

I cant use ASp.NET V1.1 else i would just use a masterpage, its got to
be Version 1.1 sorry.

Regards, and Thank You In Advance
Chris


Jun 19 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.