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--
This article will explain in detail what the foreground controls of ASP.NET are, and the editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Overview of ASP.NET foreground controls
Under asp.net, controls are divided into two categories, which are listed in the
System.Web.UI.WebControls
System.Web.UI.HtmlControls
Namespace, the former inherits from WebControl, the latter inherits from HtmlControl, and both classes inherit from System.Web.UI.Control
Well, windows platform, no matter what kind of development you are engaged in, eventually someone needs to call loadlibrary.dll.
Then the asp.net control, no matter what control you use, will eventually call Render.
The problem of ASP.NET foreground control
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 has controls, and first, it will make your final HTML code.
Expansion, in addition, it is troublesome to cooperate with js. You need to write a bunch to interact with js.
< %=Control.ClientID %>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? maybe 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.
< asp:HyperLink runat="server" ID="link">Connect text
< /asp:HyperLink>For example, simply change to connect text templates and other properties. In addition, the table control used in the background to edit data and so on is also quite convenient. But used in the foreground, GridView and other designs into art cut pictures, absolute physical work.
Some people use controls are almost obsessive-compulsive disorder, the front desk simple display to use GridView, obviously StringBuilder patchwork and concise, but also 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. Life or death didn't work. 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, I added Image.Attributes.Remove ("style") at the back desk; I still added 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.
Comments on ASP.NET foreground controls
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:
< input type=submit/button/text runat=server>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. However, for Web controls, events are generated only by the browser, but browsing
The server will not handle it, and the client will send 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 the control implements the IPostBackEventHandler interface.
This is the end of this article on "what are the foreground controls of ASP.NET?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.