First of all, let's talk about the programming idea of the object. I think the mainstream programming idea is not two: structural and object-oriented. Previously, we were completely structural ideas in ASP. Now, ASP.NET can fully support object-oriented programming ideas, this has to be said to be a qualified leap.
I remember that I wrote a "object-oriented object" from the artificial earth in about half a year. "At that time, I found that anything can be seen in an object-oriented thinking. I am still talking about it now. It is nothing more than the object to be a class. If you want to use the class, you must create an instance of the class. This is very good, thanks to the parter is a class, we can't say people to do things (so do not targeted), we tend to say Zhang San or Li Si, this three or Li Si is a class of people. An example. This is the concept of the object. Telling again is an event and action, an example: starting, raining, receiving clothes. It is getting up, raining is an event. This incident will inspire this action. This action is an object. If you have learned the trigger of SQL Server, I want to be more clear about this idea. Object-oriented is more important to inherit (inherits) and polymorphism. This is very understanding, for example, Zhang San will receive clothes, Zhang San Lifeng's son inherits Zhang San's characteristics, will also collect clothes, this is inherited, and said that Zhang San's son will drive, this is a polymorphism.
Ok, for the object-oriented understanding, let me say this, or how to program the object-oriented views in ASP.NET. When we edit the web program, we usually have to process: UI (user interface, but also data display) and code (how to handle the data of the data. In order to achieve the complete separation of the UI and Code, we treat UI as a Object, Code is an object. Of course we want to study the relationship between these two objects, remember that we will copy the same paragraph code when editing the ASP program, it seems that Code is a parent class, UI is a subclass However, they all inherited from System.Web.ui.page. Raicit the relationship of the class, we don't even understand the idea of code UI and CODE. Relationship diagram: Introduction Name Space: using system.Web.ui Parent Class Page → Many Subcador Code (*. CS Files) → Multiple Subclass UI (*. ASPX Files)
Because I mainly want to know this programming idea, I only give a simple example, I think everyone has thought, and then look for examples.
File two: UI Class: Default.aspx is mainly used to display data, use the day DataGrid control CODE class: default.aspx.cs mainly used to establish data link, query, binding data in the DataGrid control, I created my own Namespace named Vagrant, as well as class Myvagrant Database: Data, there is a relationship table Student
To illustrate the Default.aspx class inherited from default.aspx.cs, you need to declap in default.aspx: <% @ page language = "c #" codeBehind = "default.aspx.cs" inherits = "vagrant.myvagrant"% > CodeBehind indicates the source file of the parent class, inherits = "vagrant.myvagrant" indicates which class from which the file is inherited. Now give the source file default.aspx code:
<% @ Page language = "c #" codebehind = "default.aspx.cs" inherits = "Vagrant.myvagrant"%>
head>