有和没有RUNAT =服务器属性的脚本标记之间的区别 [英] difference between script tag with and without runat=server attribute

查看:161
本文介绍了有和没有RUNAT =服务器属性的脚本标记之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

主题是我的问题。

我在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆