ASP.NET V1.1 Headers and footers help

D

Dessip

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
 
B

bruce barker \(sqlwork.com\)

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

Dessip

Hey,

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

Chris
 
D

Dessip

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top