What is the difference between <script runat="server">
and <script>
?
相关问题
- Views base64 encoded blob in HTML with PHP
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
When you add
runat="server"
attribute the tag will become available in server side code like any otherasp.net
control.Then you will be able to manipulate/add c#/javascript code within the blocks directly.
If you don't add the
runat
attribute you will be able to only have client side scripting.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.eg if you declare a div like so:
from the code behind you can do this:
<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.This article has some info: http://msdn.microsoft.com/en-us/library/f0111sbh(v=vs.100).ASPX
<script>
is used in order to include client-side code (usually javascript)http://www.w3schools.com/tags/tag_script.asp