In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how to achieve ASP.NET WEB control, I hope you will learn something after reading this article, let's discuss it together!
ASP.NET 's WEB controls are divided into two categories. Under the System.Web.UI.WebControls and System.Web.UI.HtmlControls namespaces, the former inherits from WebControl and the latter inherits from HtmlControl, and these two classes inherit from System.Web.UI.Control 's windows platform. No matter what development you are engaged in, you need someone to call loadlibrary.dll.
Then the WEB control of ASP.NET, no matter what control you use, will eventually call Render.
In fact, as a foreground development, most of these controls are not so easy to use.
1. First of all, it will generate a long and long ID, especially when the page inlay has controls, on the one hand, it will make your final HTML code swell, and on the other hand, it will be troublesome to cooperate with js. You need to write a pile to interact with js. There is no way. ASP.NET must be 'kind' to help us solve the problem of ID conflict. Why not separate this ID from the resulting ID? It may be that javascript was not as powerful as it is now when making this set of controls and was ignored by ms.
two。 There is also the problem of generating one more span, that is, it is not W3C and is not conducive to typesetting. When writing css, you should consider the span sandwiched in the middle.
3.form problems, many forms and other controls, to use the server side form, when there are multiple form, can only use some of the form to interact with js, form in the URL rewrite there is a problem, the generation is not URL redirect back path, the server side to deal with this need to rewrite form
4. For beginners, there is also a long _ VIEWSTATE
Most of the time, when we write foreground code, we just need to simply render it. We don't need long ID, span, _ VIEWSTATE, just a few lines of clean HTML tags, but there are no options or property settings at all, either to you or not. Although we can write code like asp and ASP.NET, we always need to use it since it is provided.
WebControl also brings some flexibility. Now ASP.NET web development is basically divided into N-tier architecture. If the code is output in the logical layer, there is no way to change it without modifying the source code. Link text such as this, simple link text template and other attributes. In addition, table controls are used in the background to edit data, etc., but used in the foreground, GridView and other designs are cut by artists. Absolute manual work.
Some people use ASP.NET WEB controls are almost obsessive-compulsive disorder, the foreground simple display has to use GridView, obviously StringBuilder patchwork is concise and efficient.
I encountered a strange problem a few days ago. I wanted to do an effect. I moved the mouse over the picture, highlighted the frame, and the artist was ready to add it to the code. I didn't know what was going on for a long time. Later, I inadvertently found all the Image controls and automatically added them. All right, Image.Attributes.Remove ("style") is added everywhere; there is still Image.Attributes.Clear (). Still, the pair is a stupid design, probably to solve the problem of the default 1px border of the img tag sandwiched in the a tag, but there is no way to use css to deal with the border attribute of Image.
My most commonly used controls:
Literal is clean and convenient. Piece together HTML code, js code
Repeater clean list
Placeholder control display logic
The most stupid control:
For Image reasons, please see the above.
The most worthless control:
Label span set literal on the line, the style to artists to solve, do not see any practical value.
Hard to use controls:
Datalist, gridview generate div or list layout is very tiring (only refers to the front desk)
Other controls depend on the occasion.
In addition, there is such a difference between HtmlControl and WebControl on the Internet, which is purely misleading. I really can't go on watching it. Explain.
1. It is also quite easy to use. Take a simple example, such as the generation of Button:
The Html control is to get all the large sets of controls into the page. Set the properties for which function is used, as follows:
This will take up a lot of control resources.
This is purely misleading and has spread widely. In the end, they all generate HTML tags, and people like input don't need to put a huge collection of controls into the page, but end up generating a tag. The difference is just the difference between the HtmlControl and WebControl base classes.
The 2.Web control has a loopback function and can maintain the state of the control with ViewState.
The Html control cannot, when you click on the operation of the page, its state will be lost.
Protected virtual void LoadViewState (object savedState); protected virtual object SaveViewState ()
In fact, these two definitions are in the System.Web.UI.Control base class, only WebControl overrides these two methods, but these two methods are not rewritten in HtmlControl, but this is not equal to the above statement.
3. The difference between Html controls and Web controls is that they handle events differently. For Html forms controls, when an event is raised, the browser handles it. But for the Web control, the event is generated only by the browser, but the browser does not handle it, and the client sends a message to the server telling the server to handle the event.
This is a confusion between server events and client script events, whether implemented from WebControl or HtmlControl, can trigger server-side events
Handling server-side events can be done as long as controls that implement the IPostBackEventHandler interface are implemented.
After reading this article, I believe you have a certain understanding of "how ASP.NET implements WEB controls". If you want to know more about it, you are welcome to follow the industry information channel. Thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.