Core WebForm, ASP. NET knowledge (10) and webformasp.net
WebForm troubles
1. winform-based development
In the WebForm development mode, you only need to drag a control from the toolbox, and then write the event logic of the control from. aspx. cs.
Microsoft has done a lot of work for us, and many things do not need to be understood. Microsoft seems to want to make website development consistent with Winform development.
But do developers not understand the running mechanism?
2. ViewState
To save some page status information, Webform uses <input type = "hidden">. Someone told me this is called ViewState.
ViewState makes html abnormal "ugly ".
Disadvantages of WebForm
1.Easy to get started and hard to develop
Convenient and convenient server-side controls allow us to enjoy simplicity while bringing us endless troubles. If it is just a Drag Control, it is easy for beginners to get started. However, because many things are too encapsulated, many underlying things are hard for beginners to understand and want to improve.
2. Inflexible Control
It is difficult to control the presentation of page data.
3.ViewState Processing
This mechanism makes development easier. But it also makes html very bloated and ugly.
4.Asynchronous request
For asynchronous requests, no common handler is allowed in the backend of each request.
5.Easy to become silly
The WebForm development method is inconsistent with the traditional Web development method. What traditional web development must know, many of which are not needed here, such as http, ajax, and javascript... In short, the controls are rich and you don't need to know much about them.
We recommend that you use WebForm easily.
This article is actually quite tangled. Since there are so many webforms, do you need to use it? You don't have.
My understanding is as follows: first, for. NET development, many people are the first to respond to WebForm (although they may not use this, this kind of thinking is quite strange .) Just like selling on the street, insiders know that the "Broken chest Stone" is fake. But as a selling artist, if I tell people that I won't "break my chest into rocks", I'm still a little shy. Second, in many cases, what technology is used during development is not determined by us. In case of a program developed by webForm, it will not be changed. So I suggest a little bit better. Be sure to understand it.
1. aspx page
We recommend a lightweight WebForm method. In this case, just make a list function.
/* In the aspx file, html and code mixing are supported. Although you may think it is messy, webform is a solution that is justified in the past. */<Table> <thead> <tr> <th> name </th> <th> age </th> <th> gender </th> <th> edit </th> </tr> </thead> <tbody> <% for (int I = 0; I <persons. rows. count; I ++) {System. data. dataRow row = persons. rows [I]; %> <tr> <td> <% = row ["Name"] %> </td> <% = row ["Age"] %> </td> <td> <% bool gender = (bool) row ["Gender"]; Response. write (gender? "Male": "female"); %> </td> <a href = "PersonAddNewEdit. aspx? Action = edit & id = <% = row ["Id"] %> "> edit </a> </td> </tr> <% }%> </tbody> </table>2. aspx. cs File
// Model: you do not know how to be displayed, nor how the protected DataTable persons; protected void Page_Load (object sender, EventArgs e) {// query data, put the data in the Model, and do not know how the data is displayed. persons = SqlHelper. executeQuery ("select * from T_Persons ");}