Showing posts with label couple. Show all posts
Showing posts with label couple. Show all posts

Thursday, March 22, 2012

Newbie-time: OOP and ASP code separation?

Couple of softball questions on OOP and ASP.NET:

1. I am a bit uncomfortable with tangling class code with UI elements (e.g. result.innertext = object.method). Is it more customary to store some of the heavy-lift object class code elsewhere and simply call the objects from the aspx.cs. So, the aspx.cs does minimal processing, instead mapping results to the appropriate form elements?

2. If yes to #2, do I simply add new classes to my project? Is there any disadvanatge to this?

My thanks!

Paul

Hi,

yes you can put your heavy lifting in separate classes and call these from your codefile. In ASP.NET 2.0 you can keep those classes in the App_Data subfolder. You can even intermix several different .NET enabled languages:Using VB.NET and C# in the same ASP.NET 2.0 project.

Also take a look at thePersonal Starter Kit which shows some examples of this as well.

Grz, Kris.


Thanks for the help. I am off and running.

p

Newbish questions but need advice

Ok , Im trying to convert a page I made in PHP to ASP and it sounded a lot easier than it is. So I have a couple questions.
First question
The page I created requires a lot of functions. Is there anyway I canhave an include file at the top of the page or do I have to have allthe functions listed out at the top?
Second question
How do I maintain the same look across all page? In PHP i could simplyhave each link change the page state and certain things would loadbased on the page state. I figured a way to get around this would be tohave like the standard look as an include file at the top of each pagebut I havnt figured out how to do this yet.
Any help is greatly appreciated.

1. Check out this tutorial on Function Libraries:
http://aspnet101.com/aspnet101/tutorials.aspx?id=43

However, if the functions/subs are written in concordance with ASP.Net practices, you can also use includes, just as you can with Classic ASP and PHP

2. Stylesheets work with ASP.Net, just like they work with any HTML page. - - if this isn't what you're talking about, please expand on your question so we can get a better idea of exactly what you're trying to accomplish.