That s Not ASP


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

That's Not ASP!

The desire to separate code from content and to receive the benefits received from such separation is not new to ASP.NET. In fact, developers have been striving to do this for some time, especially with classic ASP, which relied on code render blocks instead of code declaration blocks. This caused a problem known as "spaghetti code," where code was intermingled with HTML throughout a page. This made it very difficult to debug and modify the pages because developers had to search through an entire page to find errors. With code declaration blocks, this problem is mostly solved because all code is in one location: at the top of the page.

With classic ASP, developers relied on server-side includes to separate their code from their content. These files could contain any type of code, including HTML, so they were often used to hold common UI functionality. Server-side includes, although still available for use, are typically replaced with user controls or code-behind forms in ASP.NET. Both user controls and code-behind forms offer greater programmatic control than server-side includes, which technically offered none.

Resource files are new to ASP.NET. Developers familiar with compiled languages such as VB and C++ might recognize these files. They were commonly used in those languages for the same reasons you learned about today: simply to separate code from content. Classic ASP has no built-in way to store localizable information separate from the page, so multiple versions of entire sites often had to be created. In addition, classic ASP didn't allow modification of culture and region information.

All these new capabilities make ASP.NET much more versatile than classic ASP. Developers now have many more options when designing the code layout on their pages.


    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 © 2008-2017.
    If you may any questions please contact us: