what difference between using a script tag and code behind in asp.net
The <script> tag in asp.net is used to define the client-side script. The <script> tag contains the scripting statements, or it points to an external script file.
Code Behind refers to the code for an ASP.NET Web page that is written in a separate class file that can have the extension of .aspx.cs or .aspx.vb depending on the language used. Here the code is compiled into a separate class from which the .aspx file
derives. You can write the code in a separate .cs or .vb code file for each .aspx page. One major point of Code Behind is that the code for all the Web pages is compiled into a DLL file that allows the web pages to be hosted free from any Inline server code.
Best regards,
Sam
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
To add to what samwu said, code behind runs on the server, not in the local browser. Javascript runs locally. You need to know the difference between what runs locally and what needs information sent back to the server to be handled.
I'm surprised that the book you are reading does not specifically state this fact. Seems a little odd... Anyway, notice the script tag has a runat="server" attribute. ASP.NET Web Forms allows you to have a separate code behind file or a single file that
combines markup and server side code.
To expand on mgbehard's response, that script section is actually C# code-behind. The runat="server" attribute means it runs on the server. You are looking at an .aspx example where the code behind is in a runat="server" script section in the .aspx page
rather than in an associated, separate .aspx.cs file. Either way works. For larger pieces of code it is easier to maintain in a separate code file.
And, repeating what I said earlier, ASP is not ASP.NET. Your example is ASP.NET.
Member
9 Points
33 Posts
asp script
Dec 31, 2019 08:22 PM|mrzoz|LINK
Hello friends;
what difference between using a script tag and code behind in asp.net
Contributor
3370 Points
1409 Posts
Re: asp script
Jan 01, 2020 01:49 AM|samwu|LINK
Hi mrzoz,
The <script> tag in asp.net is used to define the client-side script. The <script> tag contains the scripting statements, or it points to an external script file.
Code Behind refers to the code for an ASP.NET Web page that is written in a separate class file that can have the extension of .aspx.cs or .aspx.vb depending on the language used. Here the code is compiled into a separate class from which the .aspx file derives. You can write the code in a separate .cs or .vb code file for each .aspx page. One major point of Code Behind is that the code for all the Web pages is compiled into a DLL file that allows the web pages to be hosted free from any Inline server code.
Best regards,
Sam
Contributor
5961 Points
2466 Posts
Re: asp script
Jan 01, 2020 02:24 AM|KathyW|LINK
To add to what samwu said, code behind runs on the server, not in the local browser. Javascript runs locally. You need to know the difference between what runs locally and what needs information sent back to the server to be handled.
Member
9 Points
33 Posts
Re: asp script
Jan 01, 2020 01:18 PM|mrzoz|LINK
hi friends
sorry I'm confused because I read a book on asp
not asp.net
there is a script
I don't see asp
but I think the asp code previously run from a script the c# or vb.net run from a script is this ok in the previous version of asp
All-Star
53021 Points
23601 Posts
Re: asp script
Jan 01, 2020 03:45 PM|mgebhard|LINK
Classic asp uses VbScript.
https://www.w3schools.com/asp/asp_syntax.asp
Classic asp powered web applcation from the late 90s to the early 2000s.
Member
9 Points
33 Posts
Re: asp script
Jan 01, 2020 04:07 PM|mrzoz|LINK
PLS LOOK TO THIS IMAGE
IS THIS ASP OR ASP.NET
https://www.dropbox.com/s/c1dqyjaj2wv3kgg/ScreenshoASP%20OR%20ASP.NET.png?dl=0
All-Star
53021 Points
23601 Posts
Re: asp script
Jan 01, 2020 04:14 PM|mgebhard|LINK
That's ASP.NET.
I'm surprised that the book you are reading does not specifically state this fact. Seems a little odd... Anyway, notice the script tag has a runat="server" attribute. ASP.NET Web Forms allows you to have a separate code behind file or a single file that combines markup and server side code.
Contributor
5961 Points
2466 Posts
Re: asp script
Jan 01, 2020 05:07 PM|KathyW|LINK
To expand on mgbehard's response, that script section is actually C# code-behind. The runat="server" attribute means it runs on the server. You are looking at an .aspx example where the code behind is in a runat="server" script section in the .aspx page rather than in an associated, separate .aspx.cs file. Either way works. For larger pieces of code it is easier to maintain in a separate code file.
And, repeating what I said earlier, ASP is not ASP.NET. Your example is ASP.NET.