Main content of this book
Most developers have such experiences in learning Asp.net. They have been using Asp.net for many years, but still feel that they have little knowledge about Asp.net technology and have a vague understanding of knowledge points, in our work, we often receive demanding control function requirements. We often avoid the need for personnel for reasons that the control does not support, and we are lucky enough to escape. However, this is not a long-term plan. To improve the performance of the Asp.net technology, you must first understand its working principles and the working principles and presentation processes of pages and controls.
This book mainly introduces ASP. net control development, the book through more than 70 examples to explain ASP. net Control Development Technology in various aspects, and analyzes a lot of control system base class source code, and from these system source code can understand the design mode idea. If you have mastered the operating mechanism of ASP. NET controls, developing a page-level ASP. NET application will become very simple. This book aims to let developers really understand ASP. NET technology and help developers improve the technical level of ASP. NET development. After learning this book, you can not only master various aspects of control development technology, but also understand the working principles of ASP. NET. For developers who have been using Asp.net for about two years, more than 75% of the content in this book may not be reached, this book will elaborate on these contents through examples of the image carefully prepared by the author. For more information about this book, see the following url: http://blog.csdn.net/ChengKing/archive/2008/08/18/2792440.aspx
This book introduces the Asp.net Control Technology to Improve the Asp.net Technology of developers. It is suitable for the staff who have been engaged in Asp.net Technology for many years and want to have a deep understanding of the working mechanism of Asp.net. Based on the preliminary developers who have just started Asp.net, in the previous chapters, I also introduced several application examples to help beginners. Microsoft's Asp.net technology has evolved from three major versions and has become a mature technology, it is also widely used in software enterprise applications. This book can also be used as a pre-employment teaching material for students at school. This book can help you understand the most popular Web-based application presentation process. In addition, for different development environments installed by readers, I have created two solutions for VS 2005 and vs 2008 respectively, that is to say, whether you are developing in VS 2005 or vs 2008, you can successfully open the code of the book CD, but the solution that uses VS 2005 does not contain. net 3.5.
Operator order
Many developers have such experiences using ASP. net has been developed for many years, but I feel that the level is always not improved. I even find that senior developers with more than five years of work experience on ASP. NET technology is not very deep. The main reason is that in the development process, we only focus on the breadth (horizontal) to learn a variety of technologies, including the latest technologies, rather than the depth (vertical) After mastering a technology. Although many developers have many years of experience, they only use ASP. NET Technology Development page-level applications (page developers), without or without access to ASP. net underlying technologies, such as the page rendering process of Web applications. These technologies are not limited to ASP. net, but something that must be mastered in the B/S architecture based on the Web platform.
For example, a cow seems to be full of meat, but if we take a knife to slaughter a cow, we will know that it is not that easy. It is not only a great deal of effort not only to use a knife to cut it without regularity, in addition, it is likely that the ox will eventually be chopped into a mess, because the ox's body structure is unfamiliar and cannot be correctly inserted into the knife; the chef of Wen huijun, the master of Chuang Tzu's health care, would not have been able to beat the ox because he knows the structure of the ox well, this is the so-called depth (vertical in-depth research ).
Learning ASP. the same is true for the net technology. If you only have a taste of the technology at work, it is difficult to improve your technical level. The main purpose of this book is to use the "ding Jie niu" technique to parse ASP. net.. net.
Running Environment
The development environment described in this book is mainly based on Microsoft's latest framework. NET Framework 3.5 and integrated with the development environment vs 2008. All the examples on the CD-Rom in this book are verified in the ie 7.0 browser.
. Net Framework 3.5 is fully compatible with earlier versions, that is. the control class library in versions earlier than Net Framework 3.5 is. net Framework 3.5, based on which I made a set of examples in the accompanying book CD with the VS 2005 Development Environment (only missing. NTE 3.5 new features, such as Ajax controls ). This allows friends who use VS 2005 or vs 2008 to open the control project in the CD. Many technical points in the book are compared and analyzed in VS 2005 and vs 2008 development environments.
The subject and features of this book
To be precise, ASP. NET is a technology rather than a language. The premise of mastering a technology is to understand its working principles. Relatively speaking, learning ASP. NET is much harder than learning a language.
The purpose of this book is to allow developers to truly understand ASP. NET technology and help developers improve ASP. NET development technology. The content in the book mainly focuses on control development, if you have a solid grasp of ASP. to develop a page-level ASP. net Applications will become very simple. After learning this book, you can not only master the control development techniques, but also have a thorough understanding of ASP.. net.
This book does not explain how to use ASP. NET controls, but how to develop controls. In the process of explaining the control development, we analyzed the source code of many control systems and made more contact with them. the source code of the Net Framework will have a deeper understanding of the design pattern, which is a practice compared to the theory in the book. What is the relationship between control development and design patterns?
Design Mode: In the process of inheriting the system base class to develop custom controls, careful developers may find that basically all the base classes of the system have a basic design pattern-template method pattern, which is characterized: the skeleton defined by the base class is driven by the base class (for example, the execution of methods at each stage of the control's lifecycle is driven by the base class), and the base class provides the most common default implementation, the same Code is extracted from the base class for code reuse. The advantage is that, in most cases, when developing our own custom controls, we can implement a control by writing very little code (or nothing, for example, see the following code:
Public kingtextbox: textbox
{}
The above Code does not write an implementation code, but it is still a complete control, reusing all functions in the base class. When the functions we need are different from those of the base class, you only need to override some methods of the base class to implement the necessary functions. The default implementation of other functions of the base class is still used, it should be noted that, unlike implementing our own business classes, we need to encode every method in the class. In addition, in the control development technology, this design mode can be used to unify the cumbersome tasks by the system base class, so that developers can avoid errors in a certain process.
Design Patterns are object-oriented formulas. I personally have read many books on design patterns and are also interested in design patterns. I personally think the best way to learn the design pattern is to read a few books first, thoroughly understand and read a lot of source code, and often have an epiphany; otherwise, I may have understood a piece of code in the classic design pattern, I don't know what the design pattern is. I just read the code. In control development, if you want to learn more, you must look at the system control code in. NET Framework. Without knowing it, you will improve your development capabilities and object-oriented thinking.
The content of this book is not about the design model, so I will talk about it here. If you want to learn more about object-oriented, I still want to remind you not to be limited to only understanding the code when looking at the system source code, but also to look at the relationship before the system base class and think about why their classes should be designed in this way.
Some important knowledge points in the book may never be used by developers at work, but these knowledge can give you a more thorough and profound understanding of ASP. NET technology.
In addition, the advantage of the control development work is that there are more opportunities for practical object-oriented applications. For example, there are many interfaces in the control. A good control is not only powerful, good performance, but also easy to reuse, whether it is easy to expand and whether it can implement the required functions with as few code as possible.
After reading this book, you will be able to understand the ASP. NET page and the process of generating each element. ASP. NET development is essentially the process of applying controls. Each control we use on the page, or even the page, is derived from system. web. UI. the page control class is a special container control, and its generation cycle is the same as that of the general control, the book also provides some knowledge points to explain the page control operation mechanism. It is very easy to develop a page after you know how controls work. You can also say that learning control development is an effective way to accelerate ASP. NET technology.
This book focuses on the combination of theory and practice. For each ASP. Net control development technical knowledge point, there will basically be a corresponding example application.
In terms of Chapter classification, the sections are classified by technical point category and the content is comprehensive. Each control development technical point is elaborated in detail. This book can also be used as a search manual.
What makes me want to write this book?
At first, I only wrote the control development experience on my blog. Later I found it trivial to write it on my blog. The biggest drawback is that it cannot ensure the consistency of knowledge points, it is also impossible to systematically explain a complete technology from the beginning to the end. Gradually with the increase of development experience, I began to write this book, and even the book was finally published.
This book can help readers improve ASP. NET development skills. For me, it is also a systematic summary of my work in recent years. In the process of writing a book, I have also improved my skills.
ASP. NET technology can be said to be a great technological revolution, but it also brings some hidden risks to developers, because it makes programmers "silly", web server technology is a more complex technology, if programmers are engaged in development at the beginning, they will encounter ASP. net, it will think that the development of web programs is as simple as the C/S architecture, so that programmers not only do not understand the Client technology, but also because ASP. net's ease of use (to achieve ease of use, some web technologies are closed to the underlying layer) so that programmers do not know much about server-side technologies. I am angry with this, which is another important reason for writing this book. I found that many developers are interested in ASP. NET technology has little understanding, and my friends who work with me and even have years of development experience have some asp. net basic principle is unknown, it can be said that after all because ASP. the emergence of net technology and the integration of the development environment have made many developers become "silly" programming, so that developers have no chance to understand those things.
Taking ASP. NET as an example, some common mistakes made by developers:
Clear the server and client ID of the control
There is a server control with the ID textbox1 on the page. Many developers use the following statement when accessing the DOM element of the control on the client:
VaR txtbox = Document. getelementbyid ("textbox1 ");
One day later, he suddenly found that the Code had a problem and could not retrieve the client elements of the textbox1 control through the code above. This method is incorrect for server controls. The correct method is:
VaR txtbox = Document. getelementbyid ('<% = textbox1.clientid %> ');
The error occurs because they do not understand that the server control does not have only one ID as the client control. The server control has three properties that indicate the unique names of the control. These three attributes are ID, uniqueid, and clientid. The ID indicates the ID we name it. This ID is not used in both the server and client programs. The uniqueid indicates the server ID of the control and indicates the unique name of the control on the server; clientid indicates the Client ID of the control. It is the unique name of the element on the client tag page. From the perspective of usage, if the inamingcontainer interface is inherited, when we set an ID for the Child control, its uniqueid and clientid will automatically add the parent Control name and separator as the prefix. In general, the server separator is separated by "$" by default (uniqueid), but the client will automatically convert these "$" to "_" (clientid ), that is, the client ID is the same as the server ID, but the Delimiter is different.
The cause of the above Code error is that one day he put the textbox1 control into the master page container control. Before adding the master page, because the textbox1 control does not have a parent container, its ID, uniqueid, and clientid are both "textbox1", which is just a coincidence. Once textbox1 is placed in the container control, its uniqueid and clientid change. You need to add the parent container name as the prefix. For example, its clientid may change to panel1_textbox1, and the server uniqueid will change to Panel1 $ textbox1. I will not elaborate on it in depth, but I will explain it in this book.
Misuse of system-level objects provided by ASP. NET
Some developers do not understand the viewstate (including cache and session) mechanism, which leads to misuse during the development process. For example, we mistakenly believe that viewstate is stored on the client (on the surface, it is on the page) rather than the server, and viewstate is used as a massive container, even cache the Business List data on the page to the viewstate, resulting in huge page traffic. The page opening speed is very slow, but the cause is not found.
Learning a technology is different from learning a language. First, you must understand ASP. net object mechanism. Simply put, the workflow of viewstate is as follows: each time it is submitted, it will be passed back and forth in the form of a client to the server. After processing is complete, the new result is stored as a hidden field in the page as a new viewstate and returned to the client together with the page content.
The reason for the slow page is that developers do not understand ASP. NET page rendering process, mistakenly store the serialized string of business-level data to the hidden controls on the page, resulting in the huge number of page bytes, making the transmission speed a bottleneck. Viewstate is a key/value string that stores a small amount of data. The page status (view status and control status) is saved in Chapter 6th.
Another friend asked me how to run a piece of JavaScript code on the server while submitting the page, instead of running it on the client? Some may ask, How do I execute a Javascript script between two server code segments?
The most fundamental reason for these problems is that the developer has. NET Technology Operating Mechanism is not clear about ASP. NET Server Control lifecycle, it is unknown that the client script must be executed on the server before it is executed on the client.
Building software with object-oriented thinking can bring many benefits, such as encapsulation, scalability, and so on. I will not list them here. What I want to talk about here is the hidden danger that object-oriented brings to developers. Many developers derive and develop object-oriented development without understanding the basic classes. If object-oriented technology is used, it is really dangerous to not understand the base class. The base class here refers to the system base class, third-party component base class, or self-developed base class. The system base class is the most understandable and most easily ignored.
For example, in a derived class, we usually use a base-like method. methods of method name (parameter) statement format, especially in the control development process, are basically derived from the system control base class to develop their own controls. For example, a simple base. when using the render (e) method, I encountered so many application scenarios during the development process: Sometimes this statement is not called; sometimes it must be called; sometimes it needs to be called, but the base class base needs to be blocked. some functions in the render (e) method body or some modifying functions; sometimes the base is not called but must be executed. some code statements in the render (e) method, and so on. To implement so many scenario functions, you must first understand the base. Render (e) method, and more specifically, you should understand the entire base class. There are also many developers who do not know the functions of the method in the base class, use examples to guess the test, and learn about its functions based on the call results, however, in many cases, this method is inaccurate. The best way is to thoroughly check the source code of the base class.
Based on this, another major feature of this book is that, when explaining each control development type, the system will first inherit the control base member (base class or base Interface) provided by the system) for detailed parsing. This not only makes developers feel comfortable during development, but also helps them develop more accurate and accurate controls.
My promise
If you have not. net Control has studied ASP. NET development, read this book on ASP. NET technology is improved by three times. For developers who have been engaged in development for a year or two, more than 75% of the content in this book may not be reached yet. This book analyzes ASP. NET just like "ding Jie niu", provided that you have patience to read this book. This book introduces some asp. net advanced programming technology, some technical beginners may be difficult to understand, in this case do not be discouraged, as long as you insist on reading the book will be consistent technology.
In addition, each example in the book can be found in the corresponding chapter on the CD-Rom. Each time you read an example, you need to run the actual example. These examples not only illustrate each control development technology, more importantly, it provides some experience in control development solutions.
This book is suitable for readers
This book explains ASP. net control technology to help developers improve their own ASP. NET development level, suitable for ASP. NET technology development for many years, hope to have a deep understanding of ASP. net Working Mechanism staff, considering ASP. net beginners, in the first few chapters of this book, also introduced several application examples to help beginners get started. Microsoft's ASP. NET technology has evolved from three major versions to more mature technologies. Currently, it is widely used in software enterprise applications. This book can also be used as a pre-employment teaching material for students.
Not myself.
First of all, I would like to thank my eldest brother Xin and Lin siyong for their recommended orders for this book, as well as experts (du Yong, Zhu Yu, Wang Tao, Li huijun, Gao Yang, Meng xianhui, Su Peng, Zhang Bo, ye fan, li honggen) with your book reviews, the book is just as powerful.
Secondly, I would like to express my gratitude to the bloggers who provide technology sharing. Even if we don't know each other, sharing your knowledge is the source of my knowledge progress. In particular, I would like to thank Mr. Du Yong, the online home-blog park, for his reference to the Technical Expert Base, whether in my writing or at work, you can always provide solutions in time when I encounter difficulties.
In my work, my colleagues who are closest to me every day are my siblings. Thank you for your guidance on my technology and your care in my life. Thank you!
I would like to express my sincere gratitude to all the editors of this book, including Li Bing, Xu Yan, Li Ling, and all the related staff of the Electronic Industry Publishing House. The publication of this book is inseparable from your guidance and your hard work, especially in the course of writing this book, Li Bing is always patient and encouraging, and Xu Yan is careful about the approval of the manuscript, and Li Ling is very creative in the design of the book, thank you again for your special thanks.
I would also like to thank my family. When my parents gave birth to raise me, your kindness is hard to return even when the environment is closed. You care for me with meticulous care, so that I can concentrate on writing. I would like to thank Zhao Jing, my newly-married wife, for her full support during my book writing. When I was busy writing a book, I always ignored you by my side, even in the bright autumn, I cannot accompany you on an outing in Nanshan, but you have no complaints or encouragement, so you cannot publish a book. Family care is always so warm, I hope to dedicate this book to my dear family.
Finally, I would like to thank you for your extraordinary perseverance and strong character. I can work hard to pursue my own ideals and never give up. My motto: to do something meaningful, try to finish it as quickly as possible.
Now read this book content: http://productp.dangdang.com/product.aspx? Product_id = 20540701
Appendix: online purchase book:
[Dangdang purchase]
[China-Pub purchase]
[Amazon excellence purchase]
Zheng Jian, September