This article describes the usage of <script runat="server"> and is shared with you for your reference. The details are as follows:
In the .aspx page, you can add code in the <head>code</head> tag through <script runat="server">. In fact, the code here and the code in the .cs file have the same status, and are both executed on the server side.
example:
void Select_Change(Object sender, EventArgs e)
{
("Select Changed!");
}
</script>
As you can see, you can also use the server side () to output the content.
It should be noted that in <script runat="server"> </script>, only methods and attributes can be placed, and statements and expressions cannot be added directly.
In addition, in the .aspx page, you can also use the <% %> tag to reference the server-side variables, or display the server-side function return value to the client. However, the use of this tag has certain limitations, in which functions or subroutines cannot be declared, and statements can only be placed.
In practical applications, it is best to write the front and backend code separately, which not only makes the code clear and clear and easy to manage, but also fully reflects the difference from ASP.
I hope this article will be helpful to everyone's programming.