The Drive for Separation

IOTA^_^    

Sams Teach Yourself ASP.NET in 21 Days, Second Edition
By Chris Payne
Table of Contents
Day 19.  Separating Code from Content


Recall from way back in Day 2, "Building ASP.NET Pages," that ASP.NET strives to simplify code writing for developers by allowing them to group ASP.NET code and HTML code separately. For instance, most, if not all, ASP.NET code should be written in SCRIPT blocks, at the top of an .aspx file, separated from the HTML code. Figure 19.1 illustrates this.

Figure 19.1. The ideal way to structure ASP.NET pages.

graphics/19fig01.gif

Writing code this way is beneficial for a number of reasons: It's easier to modify the code and HTML; it presents a more logical view of the page; you don't have to search for code render blocks throughout your pages. ASP.NET allows you to do more than just this, however. You can separate the code from the page content completely with code-behind forms and resource files. The first approach allows you to move code into separate files, whereas the second allows you to place commonly used values (such as custom error descriptions) in one location, apart from your pages.


    IOTA^_^    
    Top


    Sams Teach Yourself ASP. NET in 21 Days
    Sams Teach Yourself ASP.NET in 21 Days (2nd Edition)
    ISBN: 0672324458
    EAN: 2147483647
    Year: 2003
    Pages: 307
    Authors: Chris Payne

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net