什么是 .NET 中的页面指令
我正在准备 Microsoft 认证考试,考试中“内容”的一些措辞让我感到困惑。在 MS 考试网站,在开发Web表单页面下,它说关于考试内容......
此目标可能包括但不限于:页面指令,例如 ViewState、请求验证、事件验证、MasterPageFile;客户端ID模式;
我的印象是页面指令引用了 @Page 关键字,并且 @Page 部分中定义的关联值是属性/属性。但考试内容的措辞几乎暗示@Page关键字的属性/特性是指令。
有人可以帮我解决这个问题吗?
I'm studying up for a Microsoft Certification exam, and some of the wording for the 'content' in the examn confused me. In the MS exam website, under Developing Web Form Pages, it says in regard to the content on the exam...
This objective may include but is not limited to: page directives such as ViewState, request validation, event validation, MasterPageFile; ClientIDMode;
I was under the impression that a page directive referred to the @Page keyword, and the associated values defined in the @Page section were attributes/properties. But the wording of the exam content almost implies that the attributes/properties of the @Page keyword are directives.
Could someone please clear this up for me?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为他们的措辞有点令人困惑。您是正确的,指令中的值本质上是属性。事实上,您可以在对象模型中(例如在代码隐藏中)设置大部分 AS 属性。
它们是除了
Page
之外的几个重要指令,例如Import
和Control
。我建议也熟悉这些。编辑:我很好奇这些属性在从 Page 指令设置时最终会出现在哪里,所以我查看了 ASP.Net 缓存。您可能知道,当执行页面时,它会变成一个对象并缓存在文件系统上:
c:\windows\Microsoft.Net\Framework[version]\Temporary ASP.Net Files\
我发现有趣的是这些自动生成的文件中不包含诸如 Page 指令中可能设置的属性。这让我相信该指令的完整性是在每个请求上处理的,而不是与页面一起编译的。
编辑#2:根据下面 BurningIce 的评论,我进一步深入研究了这一点。我相信指令属性可以描述如下。
指令上的每个属性都有以下一个或多个目的:对编译器的提示(例如代码隐藏路径)、加载页面的提示(例如页面继承自哪个类)、渲染页面的提示(例如 MasterPageFile),和/或在创建的页面的每个实例上设置的属性(例如标题)。
I think their verbiage is a little confusing. You are correct that the values within the directive are essentially properties. In fact, you can set most of these AS properties within the object model (e.g. in the codebehind).
Their are several important directives besides
Page
, such asImport
andControl
. I would suggest being familiar with these as well.EDIT: I was curious where these attributes end up when set from the Page directive, so I took a look at the ASP.Net cache. As you probably know, when a page is executed it is turned into an object and cached on the file system in:
c:\windows\Microsoft.Net\Framework[version]\Temporary ASP.Net Files\
What I found interesting is that properties such as one might set in the Page directive are not included in these auto-generated files. This leads me to believe that the directive in its completeness is processed on each request and is not compiled along with the page.
EDIT #2: Per BurningIce's comment below, I dug into this further. I believe directive attributes can be described as follows.
Each of the attributes on a directive serves one or more of the following purposes: A hint to the compiler (such as the codebehind path), a hint to load the page (such as what class the page inherits from), a hint to render the page (such as MasterPageFile), and/or a property to set on each instance of the page that is created (such as Title).
page 指令是您可以直接在 Page 对象本身上设置的属性和 asp.net 编译器的指令的组合。
此页面显示所有属性的列表 http://msdn.microsoft.com/en -us/library/ydy4x04a.aspx。
引自页面:定义 ASP.NET 页面解析器和编译器使用的特定于页面的(.aspx 文件)属性。
"" 这些新页面将显示所有属性的列表和一些解释属性/属性:
上面提到的旧链接, http://msdn.microsoft .com/en-us/library/ydy4x04a.aspx 不再有用。根据目标,最新链接位于 http:// /msdn.microsoft.com/en-us/library/t8syafc7(v=vs.100).aspx 和 http://msdn.microsoft.com/en-us/library/vstudio/ydy4x04a(v=vs.100).aspx ,供所有寻求此信息的人使用。
The page directive is a mix of properties that you can set directly on the Page-object itself and instructions to the asp.net compiler.
This page shows a list of all properties http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx.
Quote from the page: Defines page-specific (.aspx file) attributes used by the ASP.NET page parser and compiler.
"" These NEW pages will show a list of all properties and somewhat of an explanation of the properties/attributes:
The old link noted above, http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx , is no longer useful. The newest links are, by objectives, at http://msdn.microsoft.com/en-us/library/t8syafc7(v=vs.100).aspx and http://msdn.microsoft.com/en-us/library/vstudio/ydy4x04a(v=vs.100).aspx , for all seeking this info.