In those years, I was still studying asp.net (ii) study notes.

Source: Internet
Author: User

In those years, I was still studying asp.net (2)

In those years, I felt that watching videos was easy to understand. However, this problem was that I felt too slow to read a book quickly, so I had to read some books after learning about it, maybe the book is not necessarily good, but the book will talk about every place that should be said to have a preliminary understanding. For example, the introduction of. NET platform, components, and other knowledge, so we started to learn more about asp.net in those years.

I. Learning about asp.net preparation

As I learned in the previous years, I had to have a certain understanding of them before I started:

1. Basic use of html

2. CSS + DIV learning, supporting the basic layout

3. Javascript basics. In the initial stage, especially for DOM operations.

4. Understand the use of basic asp.net controls

Ii. Start learning asp.net

1 ,. NET platform concepts, such as CLR (runtime in public language), IL (intermediate language in Microsoft), JIT (instant compiler), CTS (general type system) CLS and. NET FrameWork and so on. NET architecture,

 

(This figure is from 51cto on the Internet)

2. The asp.net page Request Response Mechanism and HTTP Protocol are required. HTTP is a stateless protocol called Hypertext Transfer Protocol, that is, html files are transmitted between the browser and the server, when a user requests a page in the form of a URL from the WEB server through a browser, the WEB server processes the user's request and returns a WEB page to the browser for display to the user, after this process is completed, the browser will not be related to the WEB server. Based on this process, asp.net's request response is similar. When the browser requests a WEB page, the WEB server will process this request, find the requested page to locate the file. the WEB server will send the request to the CLR of asp.net, compile and execute the file, fetch the requested data from the database, generate an html file, and send it to the browser. Here are some concepts:

Dynamic page: Simply put, the requested page is a page generated by reading data from the database, such a file does not exist on the server.

Static Page: Simply put, there is such a file on the server, such as the 404 page.

B/S: browser and Server

C/S: the client and server

Iii. Asp.net Basics

1. There are many built-in objects in asp.net, which play a considerable role. Here are some common examples.

Request object: The Request object is an instance of the HttpRequest class and is automatically created to obtain the data submitted by the user in the browser and some HTTP information. common attributes include: cookies, Files, Form, Params, QueryString, and other methods, such as MapPath and SavaAs;

Response object: The Response object is an instance of the HttpResponse class and is automatically created. It also has many attributes (Cache, Cookies, etc.) and methods (Redirect, Write, etc );

Session Object: Session object. When a user opens a webpage, a Session is displayed on the server, saving some information about the current user. When the user exits or closes the browser, the Session disappears; it is often used to save the user status, such as logon and shopping cart. The usage is in the form of KEY/Value pairs, such as Session ["KEY"] = Value;

Application Object: it is a global state in the Application. It runs from the Application to the end of the Application and uses the same method as Session;

2. master pages. This is a good thing. When surfing the internet, you will often find that the beginning and end of some websites are the same, or a forum has not changed, and each page has, this can be achieved through the master page. In asp.net, the master page is a file ending with. master. It has a placeholder control to indicate the display of the Child page. The Code is as follows:
Copy codeThe Code is as follows:
<% @ Master Language = "C #" AutoEventWireup = "true" CodeFile = "Show. master. cs" Inherits = "Show" %>
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server"> <title> No title page </title> <Body>
<Form id = "form1" runat = "server">
<Asp: ContentPlaceHolder ID = "ContentPlaceHolder1" runat = "server">
// Subpage
</Asp: ContentPlaceHolder>
</Form>
</Body>
</Html>

3. A Custom User Control is. the files ending with ascx store some server controls for html and asp.net. Of course, there is also a code file that inherits from System. web. UI. userControl class, we can make some general templates into such a control, for example, using repeater and aspnetpager to complete a list control by page, so that we can reuse the code, the following is an example:
Aspx code:
Copy codeThe Code is as follows:
<% @ Control Language = "C #" AutoEventWireup = "true" CodeFile = "WebUserControl. ascx. cs" Inherits = "images_WebUserControl" %>
<Div>
<Table style = "background-color: buttonface; width: 318px;">
<Tr style = "text-align: left;">
<Td style = "background: # cccccc; font-size: 22px; color: #003399; font-weight: bold;
Width: 1284px; ">
→ News search
</Td>
</Tr>
<Tr>
<Td style = "width: 1284px; height: 26px;">
Author: <asp: TextBox runat = "server" ID = "Textbox1" Width = "214px"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td style = "width: 1284px">
Title: <asp: TextBox runat = "server" ID = "Textbox2" Width = "234px"> </asp: TextBox>
</Td>
</Tr>
<Tr>
<Td style = "text-align: right; width: 1284px;">
<Asp: Button runat = "server" ID = "button" Text = "query" OnClick = "button_Click"/> </td>
</Tr>
</Table>
</Div>

CS code:
Copy codeThe Code is as follows:
Public partial class images_WebUserControl: System. Web. UI. UserControl
{
Protected void Page_Load (object sender, EventArgs e)
{
}
Protected void button_Click (object sender, EventArgs e)
{
String URL = "AuthorName =" + Server. UrlEncode (Textbox1.Text );
URL + = "& Title =" + Server. UrlEncode (Textbox2.Text );
Response. Redirect ("Search. aspx? "+ URL );
}
}


4. The first asp.net Program

1. Open VS2010 and create an asp.net website, for example:

2. Add the DAL and BLL layers to the application, and right-click the solution> Add> new project. After the project is created, see:

 

As you can see from the figure, a project should have Styles, scripts, masters, etc. Of course, a project created using VS2010 uses Membership, and I have never used it again. Or write it yourself.

Summary

I have read a lot of books in those years and may have forgotten some of them now. This article aims to remember the days of reading books.

Related Article

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.