且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么头标记具有runat属性?

更新时间:2023-12-05 20:39:46

由于,如果您使用的母版页,你可以给自己更多的元数据添加到&LT的能力; HEAD&GT ; 标记通过添加runat属性。

Because, if you're using Master Pages, you can give yourself the ability to add further meta-data to the <head> tag by adding the runat attribute.

它也用于注入到头部标记为ASP.NET AJAX的Javascript引用(和自定义脚本注入,你可能会在页面上通过create 的ScriptManager )。

It's also used to inject Javascript references to the head tag for ASP.NET AJAX (and custom script injection that you might create on your page via ScriptManager).

修改

由于意见所指出的那样,只有这样,你可以修改任何的&LT的内容; HEAD&GT; 组中的code。我列出了两个较为复杂的情况。

As the comments have pointed out, this is needed so that you can modify any of the contents of the <head> group in your code. I listed two of the more complex scenarios.