Re: asp.net good practices?
From: Martha[MSFT] (marthage_at_online.microsoft.com)
Date: 02/07/04
- Next message: feng: "ASP.Net process idleTimeout not working"
- Previous message: Corey O'Mara: "Re: Multiple Dropdowns in a user control"
- In reply to: Karl Hungus: "asp.net good practices?"
- Next in thread: Adrijan Josic: "RE: asp.net good practices?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 6 Feb 2004 21:05:19 -0800
One of the strengths of ASP.NET is that you can very well separate
programmatic logic code from the presentation layer. The technique is
called code-behind. Each page you write(.aspx file) is compiled into a
"Page"-derived class. So you can have an intermediate class between the
"Page" class and the class generated from the .aspx file. You can add
fields, methods and event handlers in your code-behind class and have these
inherited by the class created from the .aspx file. This removes a lot of
code from the .aspx file.
The C# file should inherit from System.Web.UI.Page.
You will have to have something like this in your .aspx file:
<%@ Page language="c#" Codebehind="Somefile.aspx.cs"
Inherits="Namespace.ClassName" %>
You can write methods in "Somefile.aspx.cs" and access it in
"Somefile.aspx". You can also handle events in your .cs file.
The Codebehind attribute is added so that the C# source is compiled whenever
the page is compiled. Alternatively, you can remove this attribute and
compile your C# class into an assembly and place it in the /bin directory of
the application.
Hope this helps.
"Karl Hungus" <nnnnndddddd@hotmail.com> wrote in message
news:7ZVUb.131291$cM1.23397651@twister.nyc.rr.com...
> Looking for a high level description of good practices.
>
> I want to build a little admin tool for my site -- using asp.net, c#, and
an
> xml file as the database. Im kind of new to asp.net and im looking for a
> suggestion on how to design it so that I can read and parse the xml within
> my own objects and use the data to populate info in the html.
>
> How should I use an external .cs file with an aspx page? Is there some
kind
> of special interface I have to implement in my cs file? Or can I design a
> class (in the cs file) and instatiate it in the aspx and call methods on
it?
> Should I use databinding?
>
> Basically looking for the most modular approach with least code in the
> presentation layer.
>
> Thanks in Advance,
> Karl
>
>
- Next message: feng: "ASP.Net process idleTimeout not working"
- Previous message: Corey O'Mara: "Re: Multiple Dropdowns in a user control"
- In reply to: Karl Hungus: "asp.net good practices?"
- Next in thread: Adrijan Josic: "RE: asp.net good practices?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|