外文翻译---aspnet介绍以及内联代码和共享-jsp程序(编辑修改稿)内容摘要:
ynamically updating the Text property of the Label control. The page then rerenders to reflect the updated text. This simple example demonstrates the basic mechanics behind the server control model that has made one of the easiest Web programming models to learn and master. Note that in the preceding example the event handler for the Button was located between tags in the same page containing the server controls. calls this type of page programming codeinline, and it is very useful when you want to maintain your code and presentation logic in a single file. However, also supports another way to factor your code and presentation content, called the codebehind model. When using codebehind, the code for handling events is located in a physically separate file from the page that contains server controls and markup. This clear delineation between code and content is useful when you need to maintain these separately, such as when more than one person is involved in creating the application. It is often mon in group projects to have designers working on the UI portions of an application while developers work on the behavior or code. The codebehind model is wellsuited to that environment. introduces an improved runtime for codebehind pages that simplifies the connections between the page and code. In this new codebehind model, the page is declared as a partial class, which enables both the page and code files to be piled into a single class at runtime. The page code refers to the codebehind file in the CodeFile attribute of the %@ Page % directive, specifying the class name in the Inherits attribute. Note that members of the code behind class must be either public or protected (they cannot be private). The advantage of the simplified codebehind model over previous versions is that you do not need to maintain separate declarations of server control variables in the codebehind class. Using partial classes (new in ) allows the server control IDs of the ASPX page to be accessed directly in the codebehind file. This greatly simplifies the maintenance of codebehind pages. Although you can place code inside each page within your site (using the inline or codebehind separation models described in the previous section), there are times when you will want to share code across several pages in your site. It would be inefficient and difficult to maintain this code by copying it to every page that needs it. Fortunately, provides several convenient ways to make code accessible to all pages in an application. Just as pages can be piled dynamically at runtime, so can arbitrary code files (for example .cs or .vb files). introduces the App_Code directory, which can contain standalone files that contain code to be shared across several pages in your application. Unlike , which required these files to be prepiled to the Bin directory, any code files in the App_Code directory will be dynamically piled at runtime and made available to the application. It is possible to place files of more than one language under the App_Code directory, provided they are partitioned in subdirectories (registered with a particular language in ). The example below d。外文翻译---aspnet介绍以及内联代码和共享-jsp程序(编辑修改稿)
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。
用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。