Basic ASP. NET knowledge

Source: Internet
Author: User

The aspnet_regiis.exe-I command must be run in a few minutes.
To install the. NET Framework first and then install IIS, run the command to register the. NET Framework with IIS. After registration, an additional aspnet_client folder is displayed in the C: \ Inetpub \ wwwroot folder.

 

Ii. Web ApplicationsProgramRoot directory Operator
1. directly expressed in URL, such:

2. It is expressed in the form relative to the current webpage, for example:

3. It is represented in a way relative to the root directory of the website, for example:

4. It is represented in the same path as the current page path, for example:
// ".." indicates the upper-level directory of the current directory.

In ASP. NET, there is another method that can only be usedServer Control or serverCodeThe representation in, that is, "~" Path identifier, for example:
<Asp: Image id = "image1" runat = "server" imageurl = "~ /Images/logo.jpg "/>

Iii. Expression <%>
1. <%> is used to compile the code section of the Program on the foreground. You can declare variables and methods.

<%
  String Name = Request. Form [ " Username " ]. Trim (); // Remove spaces in the trim () method
  String Username;
  If (Request. Cookies [ " Username " ! = Null ])
{
Username = Request. Cookies [ " Username " ]. Value;
}
%>

 

2. <% = %> is used to output the value of the background variable to the foreground.

<% Int I = 6 ; %> And <% = I %> Equivalent <%=Page. ispostback%>

 

3. <% @ %> is mainly used to define pages, introduce controls, components, and set cache on Web pages:

<% @ Page %>
<% @ Assembly %>
<% @ Import %>
<% @ Mastertype %>
<% @ Outputcache %>
<% @ Previouspagetype %>
<% @ Reference %>
<% @ Register %>

 

 4. <% # %> is mainly used to bind background data to the foreground. Generally, the corresponding databind () is required in the background for binding.

Expression

< ASP: gridview ID = " Gvproducts " Runat = " Server " >
< Columns >
< ASP: templatefield >
< Itemtemplate >
<% # Eval ( " Productname " ) %>
</ Itemtemplate >
</ ASP: templatefield >
</ Columns >
</ ASP: gridview >

 

5. <%: %> bind viewdata to the Asp.net MVC Project

<% : Viewdata [ " Message " ] %>

 

6. <% $ %> in the global solution, specify the resource items corresponding to the foreground page:

< ASP: Label ID = " Lblamount " Runat = " Server " Text = " <% $ Resources: testsiteresources, totalamount %> " > </ ASP: Label >

 

Iii. aspx header code
Create An ASPX file named index. The following content is displayed on the foreground page:

<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Index. aspx. CS " Inherits = " Index "   %>

 

@ Page is a page instruction. Here language = "C #" indicates that the background code of the current page is C #, codefile = "index. aspx. CS "indicates that the page code file corresponding to this page is index. aspx. CS file, inherits = "Index" indicates that the current ASPX page inherits from the home class.
Page code (Post File) file Declaration

Public   Partial   Class Index: system. Web. UI. Page

 

From this code, we can see that the index class inherits from the system. Web. UI. Page class. Note that there is also a C #2.0 keyword partial, which indicates that the current code is a local class to indicate that this class is part of the entire web page form. When the Web server runs this pageThe ASPX page and the corresponding page code are compiled into a class file.And then generate the Il code.
The advantage of the code page separation mode is that the code of the page display part and the logic control part are separated to facilitate management and maintenance.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.