加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

.net – <%#%>和<%=%>有什么区别?

发布时间:2020-12-15 19:17:05 所属栏目:asp.Net 来源:网络整理
导读:赦免我的ASP无知,但有什么区别? 解决方法 这些有些非正式地称为“蜜蜂蜇”.有4种类型: %#%在DataBinding阶段被调用. %=%用于从代码到UI层获取值.倾向于与ASP应用程序向后兼容.不应该在.NET中使用. %@%代表directives,允许行为设置而不诉诸代码. %:
赦免我的ASP无知,但有什么区别?

解决方法

这些有些非正式地称为“蜜蜂蜇”.有4种类型:

<%#%>在DataBinding阶段被调用.

<%=%>用于从代码到UI层获取值.倾向于与ASP应用程序向后兼容.不应该在.NET中使用.

<%@%>代表directives,允许行为设置而不诉诸代码.

<%:%> (在ASP.NET 4中引入)与%=相同,但是添加了HtmlEncoding功能的输出.意图是使它成为默认使用(超过%=)以帮助屏蔽脚本注入攻击.

Directives specify settings that are
used by the page and user-control
compilers when the compilers process
ASP.NET Web Forms pages (.aspx files)
and user control (.ascx) files.

ASP.NET treats any directive block
(<%@ %>) that does not contain an
explicit directive name as an @ Page
directive (for a page) or as an @
Control directive (for a user
control).

@Esteban – 向指令添加了msdn链接.如果你需要…更多的解释,请让我知道.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读