1

How can I used include files (as used in classic asp) in asp.net 3.5 framework?

1
  • Server side includes or includes to prevent duplication of code. Commented Jun 20, 2010 at 3:24

2 Answers 2

2

You should use User Controls instead.

To share server-side code between pages, you should add C# classes to the App_Code folder.

Sign up to request clarification or add additional context in comments.

6 Comments

stupid question but why did MS make this so more complicated?
Because simple include files are poor design.
Complicated... my memory of classic ASP was that of nightmarish maintenance. In my mind the inheritance model of ASP.Net is a blessing compared with the brittleness of page includes.
Sometimes includes are a simple fact of life. For example, if you're in a organization where designers are doing the layout of everything, they're accustomed to using include files. Static or dynamic, Linux or Windows, they'll use includes. As a programmer, you could certainly turn all of them into user controls in ASP.NET, but often (at least where I work), that means designers are instantly scared to touch them and all maintenance now goes through you. At any rate, that has just been my experience.
(Goes with above) Keep in mind, this refers to repeated content that's more static in nature, such as headers, navigation, footers, etc. Obviously, reusable pieces that are more dynamic should be controls.
|
0

These were used in classic ASP to simulate a lack of any inheritance model, or composability. In ASP.Net you can use inheritance to create common functionality. Master Pages for common layout, and user controls for composability.

Inheritance will work in all three of these situations as well.

MyPage: BasePage

MyControl: BaseControl

MyMasterPage: BaseMasterPage

You have a lot of options with ASP.Net because it is built on top of an Object Oriented framework.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.