locked
asp script RRS feed

  • Question

  • User2062956768 posted

    Hello friends;

    what difference between using a script tag and code behind in asp.net

    Tuesday, December 31, 2019 8:22 PM

Answers

  • User409696431 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 1, 2020 5:07 PM

All replies

  • User288213138 posted

    Hi mrzoz,

    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

    Wednesday, January 1, 2020 1:49 AM
  • User409696431 posted

    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.

    Wednesday, January 1, 2020 2:24 AM
  • User2062956768 posted

    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 

    Wednesday, January 1, 2020 1:18 PM
  • User475983607 posted

    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.  

    Wednesday, January 1, 2020 3:45 PM
  • User2062956768 posted

    PLS LOOK TO THIS IMAGE 

    IS THIS ASP OR ASP.NET

    https://www.dropbox.com/s/c1dqyjaj2wv3kgg/ScreenshoASP%20OR%20ASP.NET.png?dl=0

    Wednesday, January 1, 2020 4:07 PM
  • User475983607 posted

    mrzoz

    PLS LOOK TO THIS IMAGE 

    IS THIS ASP OR ASP.NET

    https://www.dropbox.com/s/c1dqyjaj2wv3kgg/ScreenshoASP%20OR%20ASP.NET.png?dl=0

    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.

    Wednesday, January 1, 2020 4:14 PM
  • User409696431 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 1, 2020 5:07 PM