Asp. NET, use include

Source: Internet
Author: User
Tags variable scope classic asp
A Common way to builds the navigation and layout for A Asp-driven website be to use include files. Most Advanced ASP developers know that's the it is best to encapsulate the functionality of the Include file I n a Sub or Function, and then to call this routine from the page, which is including the file. This is avoids problems with variable scope, allows parameters to is passed easily to the include file, and makes the code EA Sier to read.
As these are sites are migrated to use ASP.net, it are likely that classic the ASP and asp.net pages would exist side-by-side, which is one of the touted advantages of asp.net. Unfortunately, there is no built-in way for a ASP.net page to take advantage of a classic ASP include file, which means T Hat the obvious solution if you want to maintain a consistent look and feel are to duplicate the look of the classic ASP Te Mplate in a asp.net user control. Unfortunately, this means duplicating presentation logic, and inevitably, the classic ASP template and the asp.net E'll get out of sync.
To overcome this problem, I built a simple user control that uses ASP. NET ' s built-in page-scraping library, HttpWebResponse, to grab a template ASP file and render it in my. aspx page. The template ASP file is simply a page so includes my presentation logic include file, and calls the functions to render The HTML, passing through any querystring parameters it has to those functions (such as in page title for a header inclu De file).
For this demonstration, there are six files:
Layout_sample.asp-this ASP page uses the include file the standard Classic ASP way.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.