asp.net equivilant to good old include files

S

Simon Harris

Hi All,

I am looking for the asp.net equiv' to ASP include files. Something which
will build common, much used parts of a page, such as header, footer
etc...

We have 3-4 developers, so ideally the code/html needs to come from a
common
place in the first instance.

Any suggestions to point me in the right direction will be appreciated.

Thanks!
Simon.
 
L

Lucas Tam

Hi All,

I am looking for the asp.net equiv' to ASP include files. Something which
will build common, much used parts of a page, such as header, footer
etc...

Take a look at Paul Wilson's MasterPages for ASP.NET 1.1. ASP.NET 2.0 will
have MasterPages built in.

We have 3-4 developers, so ideally the code/html needs to come from a
common
place in the first instance.

Any suggestions to point me in the right direction will be appreciated.


Or have you considered using User Controls? Or perhaps building
redistributable libraries which developers can share?
 
G

Guest

You could always build a class if it is a list of constents you want to share
between files or pages such as:

public class Whatever_Class{}

then on pages you want to call the class you can use say:
Whatever_Class.Method or whatever_Class.Property or what have you.
 
B

Brock Allen

Use UserControls which reside in ASCX files. These look and feel like server
side includes, but in ASP.NET are much more efficient.
 
K

Kevin Spencer

What you're looking for doesn't exist. It's like saying that you're looking
for the equivalent of 2nd gear in a car with automatic transmission. Not
only does it not have a second gear, but you have to drive it differently.

IOW, you need to change your whole methodolgy.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
J

JV

Sorry, Kevin, but I don't agree. First, an automatic transmission DOES
have a 2nd gear (and most cars will allow you to manually shift into it),
and second, I agree with the other post which recommends web user controls
for what they are trying to accomplish. Unless I misread the first post,
they just want to re-use some of their web code.
 
J

Juan T. Llibre

My personal preference is to compile whichever
classes you want to call on any page into an assembly
placed in the /bin directory.

You can call any classes in that assembly from any page.

It's clean, compact, simple to maintain, and efficient.
 
B

Brock Allen

Well, the original post was really asking for two things:

1) Standard way to do common layout of banners, footers, etc
2) Standard way to share common code

There is a different answer to each of these questions:

For #1 the answer is to use User Controls.
For #2 the answer is to factor out the common code to a shared assembly deployed
into ~/bin.
 
J

Juan T. Llibre

For sure...

I was addressing the
"re-use some of their web code" portion of the question.
 
K

Kevin Spencer

Hi JV,
Sorry, Kevin, but I don't agree. First, an automatic transmission DOES
have a 2nd gear (and most cars will allow you to manually shift into it),

Aside from being irrelevant, an automatic transmission's 2nd gear is not the
same as a manual transmissions second gear. But again, it's the point that
is relevant, regardless of the quality of the analogy.
and second, I agree with the other post which recommends web user controls
for what they are trying to accomplish.

So, how does your agreeing with those recommendations disagree with mine? Of
course you're going to use Controls (Server Controls or User Controls). If I
don't mention that it's a nice day outside, am I contending with those who
do say so? Am I somehow saying that it's a nasty day outside?
Unless I misread the first post, they just want to re-use some of their
web code.

If you read the first shallowly, yes, that is exactly what he's asking.
However, the message also conveys the fact that he's not thinking OOP, which
means that, especially since he's part of a team, they need to change the
way they think about programming their ASP.Net apps, which means they need
to re-think their whole methodology.

Assuming that he took your advice, and used User Controls, how much more
would he know about ASP.Net by doing so? He would know that one thing. He
wouldn't even know that he could write his own Server Controls, and use
them, for example. If he studies the methodolody of OOP, he will know much
more, and not need as much help next time.

Hey, if you just want to feed him a fish, I'm not knocking you for it. I
prefer to teach a man to fish.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
G

Guest

Hey Brook I don't know where you read the original post was regarding layout
of banners and footers. the messages was asking about actual code. from what
I read atleast. I don't know I might be mistaken.
 
B

Brock Allen

Hey Brook I don't know where you read the original post was regarding
layout of banners and footers. the messages was asking about actual
code. from what I read atleast. I don't know I might be mistaken.

It's Brock, not Brook :)

And the original post said:

"I am looking for the asp.net equiv' to ASP include files. Something which
will build common, much used parts of a page, such as header, footer etc..."

They then said:

"We have 3-4 developers, so ideally the code/html needs to come from a
common place in the first instance."

So the first is to use User Controls and the second is to use shared assemblies
deployed to ~/bin
 
G

Guest

Hey Brock Allen Sorry for mis-spelling your name, it was an honest mistake.
Inlude files were not only used for inserting header, footers "etc" into a
page but also programming logic. I think his message was more general then
an interface issue. Thats all I was trying to convey.
 
W

web.reports

Thanks guys for all the replies.

I was getting at mainly re-usable chunks of HTML, for header/footer.
But...This could also contain code logic, such as a dynamically
generated link to 'email this page to a friend', page title, etc.

All of our shared code is currently built in one project into one DLL,
which resides in <root>/bin. I guess I'll write classes to output the
header/footer. The thing I dont understand is how to output the HTML to
the page? Do I need to stamp the results of the class to a label/panel?

Thanks again,

Simon.
 
J

Juan T. Llibre

re:
I was getting at mainly re-usable chunks of HTML, for header/footer.
But...This could also contain code logic, such as a dynamically
generated link to 'email this page to a friend', page title, etc.

If that's what you're looking for,
I'd *really* look hard at using User/Custom Controls.

Take a look at Chapter 14 of "Programming ASP.NET",
by Jesse Liberty and Dan Hurwitz :

http://www.oreilly.com/catalog/progaspdotnet/chapter/ch14.html

It's a free read ( sample chapter from the book )
and will give you many ideas for what you need to do.
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top