Includes in .Net

T

TomB

This may seem like it's in the wrong group, but I can't seem to get a
usable answer in .net groups; and I figure that many of the people on this
group have probably dabbled in ASP.Net

In ASP I use #Includes with functions to build the look of the site.
Something like...

Include.asp
<%
Sub DrawHeader()
%>
<table><tr><td><img src=theHeader.gif></td></tr>
<tr><td valign=top>
<%
End Sub

Sub DrawFooter()
%>
</td></tr></table>
<%
End Sub
%>

Then in all of my pages I just include and call the header and footer
subroutines.

I've asked in the .Net groups how this is done and they all say "just use
user controls" but this doesn't make much sense as far as layout is
concerned. It would require me to build the layout on every page, and if I
decide to make a change, I'd have to change every page.

Any information is appreciated.

Thanks
TomB
 
B

Bob Lehmann

Use user controls.

I don't understand the part about having to change the layout. How would it
be different than ASP style includes?

Bob Lehmann
 
T

TomB

My understanding of user controls is that they are a chunk of logic. Such
as a login user control.

in my little sample, my include and function calls "draw" the basic page,
then the individual pages create the "body"
This way, if I want to change the whole site, I just edit the Include file.

For example, if my include file had the menu along the top I could move it
to the left side (throughout the site) by merely editing the include file.

If I did this with a user control, I'd have to go into each page and move
the user control to the side.

Am I missing something?

Thanks
TomB
 
B

Bob Lehmann

A user control can be just HTML. So you could have a User Control something
like the header I have in my site...

<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="titleBar" width="100%" valign="top" align="left"><a
href="~/default.aspx" runat="server"><img src="~/images/general/logo.gif"
height="60" width="220" border="0" runat="server"></a></td>
</tr>
<tr>
<td width="100%" align="left" valign="top">
<!-- Start Menu Control -->
<ais:menu id="nav" runat="server" />
<!-- End Menu Control -->
</td>
</tr>
<tr>
<td class="content" width="100%" align="left" valign="top">

This contains another User Control for navigation which can go left or right
or center...
"<ais:menu id="nav" runat="server" />"

You can have logic in the code-behind, but you don't have to. For example,
in my menu control I could check the current page and disable the link for
that page.

I don't reallyunderstand why you think you need to call subs to output the
HTML. Even with an include, if you put it in a table cell aligned left, and
you decided to align right, you would still have to change every page.

Here's a couple of groups that may help you

microsoft.public.dotnet.framework.aspnet.webcontrols
microsoft.public.dotnet.framework.aspnet.buildingcontrols

Bob Lehmann
 
T

TomB

That's it. Thanks Bob.

Bob Lehmann said:
A user control can be just HTML. So you could have a User Control something
like the header I have in my site...

<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="titleBar" width="100%" valign="top" align="left"><a
href="~/default.aspx" runat="server"><img src="~/images/general/logo.gif"
height="60" width="220" border="0" runat="server"></a></td>
</tr>
<tr>
<td width="100%" align="left" valign="top">
<!-- Start Menu Control -->
<ais:menu id="nav" runat="server" />
<!-- End Menu Control -->
</td>
</tr>
<tr>
<td class="content" width="100%" align="left" valign="top">

This contains another User Control for navigation which can go left or right
or center...
"<ais:menu id="nav" runat="server" />"

You can have logic in the code-behind, but you don't have to. For example,
in my menu control I could check the current page and disable the link for
that page.

I don't reallyunderstand why you think you need to call subs to output the
HTML. Even with an include, if you put it in a table cell aligned left, and
you decided to align right, you would still have to change every page.

Here's a couple of groups that may help you

microsoft.public.dotnet.framework.aspnet.webcontrols
microsoft.public.dotnet.framework.aspnet.buildingcontrols

Bob Lehmann
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top