What is the difference between <script runat="server"> and <script> ?
What is the difference between a script tag with and without a runat=server attribute
13.2k Views Asked by Kutti080808 At
2
There are 2 best solutions below
0
Ted
On
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:
<div runat="server" id="mydiv"></div>
from the code behind you can do this:
mydiv.Visible = false;
<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)
Related Questions in HTML
- How to store a date/time in sqlite (or something similar to a date)
- How to use custom font during html to pdf conversion?
- Storing the preferred font-size in localStorage
- mp4 embedded videos within github pages website not loading
- Scrimba tutorial was working, suddenly stopped even trying the default
- Is there any way to glow this bulb image like a real light bulb
- With non-graphical maps in Leaflet, zoomDelta doesn't work
- What can I do to improve my coding on both html and css
- Uncaught TypeError: google.maps.LatLng is not a constructor at init (script.js:7:13)
- Bootstrap modal not showing at the desired position on a web page when the screen size is smaller
- Displaying a Movie List on a Website Using Jinja2 and Bootstrap
- How to redirect to thank you page after submitting a Google form embedded into a Google Site?
- Storing selected language in localStorage
- Fences (parenthesis, braces) in HTML and MathML
- Understanding Scroll Anchoring Behavoir
Related Questions in ASP.NET
- Implementing Azure AD B2C Authentication in .NET 8 Blazor Project (RenderMode: InteractiveAuto)
- Azure Application Insights Not Displaying Custom Logs for Azure Functions with .NET 8
- IIS Rewrite Module exclude bots but allow GoogleBot
- Angular 16 sending null values to API
- I am the domain admin, newbie, how do I connect youtube.com on my domain?
- Dropdown list showing SQLServer2005SQLBrowserUser$DONSERVER instead of Active Directory group name in ASP.NET MVC C#
- ASP.NET Identity, Losing Ability to Login until Application Pool Recycles
- How to unprotect ASP.NET FormAuthentication cookie
- How does it work using ASP.NET FormAuthentication
- What is the purpose of a completely standalone 'this'?
- Is there a way to read .csproj PropertyGroup variable in c#
- MSBuild trying to copy different dll with similar name into project sporadically
- Minimizing IdentityServer4 Round Trips in Microservice Architecture with Ocelot
- Azure AD guest account in web app authentication user claims data
- Receiving 400 bad request on post when customer auth handler is used
Related Questions in SCRIPT-TAG
- Access exports on a module that is dynamically loaded through script tag?
- How to can extract data from a <script>window.Flourish
- Why does my html file not find my js file?
- Why can I import a script file from a local directory but I can't when the type is a module?
- Using A Script Tag File And calling Function From The Script In Angular Component
- The module / DOMContentLoaded event conundrum
- How do I make a script tag render all the time in react
- Chrome Extension - Force-inject inline script with Manifest V3
- How can I create a app that can be embeddable and use it as script in a React application?
- Implementing Bing Custom Search HostedUI script element in a specific react component
- What is the purpose of the number in script tag after file name?
- How to find the script tag for a chart on a website from its source code?
- How can I compile a svelte component into a one line import for a pure HTML application?
- shopify php apps api url not working in javascript
- How To Create Script Tag That Add Custom Button In Cart Page?
Related Questions in RUNATSERVER
- How to configure Nats supercluster to publish messages across two super-clusters running with different operators via gateways
- NATS custom metrics
- Nats memory usage is high how to limit it?
- Toastr notifications after ImageButton is Clicked C# aspx
- Nats client connection error with web sockets
- NATS with moleculer. How can I change NATS max_payload value?
- I can only use asp.Net to put 3 side buttons on my project
- run external exe file from dotnet core console application
- The mentioned HTML and JS code working in chrome but not in IE
- Control 'windowMasterSearchBox' of type 'TextBox' must be placed inside a form tag with runat=server
- javascript runat server arrow functions not working
- getting error 'must be placed inside a form tag with runat=server', but it is
- Why does jQuery autocomplete input break with runat?
- Apply tabindex attribute to asp:Menu control to gain focus
- Server Tags with HTML and Code Blocks inside
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
When you add
runat="server"attribute the tag will become available in server side code like any otherasp.netcontrol.Then you will be able to manipulate/add c#/javascript code within the blocks directly.
If you don't add the
runatattribute you will be able to only have client side scripting.