有和没有RUNAT =服务器属性的脚本标记之间的区别 [英] difference between script tag with and without runat=server attribute
问题描述
主题是我的问题。
我在asp.net初学者。
I am a beginner in asp.net.
之间有什么&LT的差异;脚本=服务器>
和<脚本>
?
推荐答案
的 =服务器
标记告诉.NET编译器执行服务器上的标签。它可以添加到任何HTML标记,这使得它们在服务器端code可用。
The runat="server"
tag tells the .NET compiler to execute the tag on the server. it can be added to any html tags which make them available on server side code.
例如,如果你声明一个div像这样:
eg if you declare a div like so:
<div runat="server" id="mydiv"></div>
从code后面你可以这样做:
from the code behind you can do this:
mydiv.Visible = false;
&LT;脚本=服务器&GT;
用于包括服务器端code(C#或VB.NET)在ASPX或ASCX文件无需再添加一个code-后面(的.cs)文件。
<script runat="server">
is used to include server-side code (C# or VB.NET) on the aspx or ascx file without having to add a code-behind (.cs) file.
本文章有一些信息:的http:/ /msdn.microsoft.com/en-us/library/f0111sbh(v=vs.100).ASPX
&LT;脚本&GT;
,以便用于包括客户端code(通常是JavaScript)
<script>
is used in order to include client-side code (usually javascript)
http://www.w3schools.com/tags/tag_script.asp
这篇关于有和没有RUNAT =服务器属性的脚本标记之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!