Properties of an Asp.Net Page
The extension of Asp.NET pages is .aspx. While the visual part of the pages is prepared with Html, Css and JavaScript codes, Asp.Net codes can be added to this document or stored in a separate code page.
@Page Declaration
Asp.Net pages start with this declaration line. Here, information about the page is given, such as the type of page, the programming language used in coding, the name of the code page, and how to debug it. You can see examples in the pictures below.
Inline Coding
In this method, Asp.Net codes are not written in a separate document, but between the script tags in the head of the page. It is specified that these codes will run on the server with the runat="server" parameter in the script tag. In the picture to the side, two subprograms are seen between the script tags.
This method is not preferred.
Code Behind
In this method, Asp.Net codes are kept in a separate file. The name and path of the code page are specified in the page declaration line. While the extension of the code page can be .cs or .vb depending on the language used, the filename is the same as the page it links to.
For example, if the page is default.aspx, code page will be default.aspx.cs.
This method is both safer and more understandable.
The Visual Studio program asks which method to use when creating the page. If the "Place code in seperate file" option is checked, the server codes are placed on a separate page, while the program automatically creates and connects the code page.
asp.net page structure, what is code behind, advantages of code behind, where to write asp.net codes
EXERCISES
There are no examples related to this subject.
Read 1205 times.