Atitit. componentized event-based programming model -- Server Control (1) --------- relationship between server control and label, atitit ---------
Atitit. componentized event-based programming model-Server Control (1) --------- relationship between server control and label
1. The server control is a tag that can be understood by the server. There are three types of server controls: 1
1.1. HTML Server Control-traditional HTML Tag 1
1.2. Web Server Control-new ASP. NET label 1
1.3. Validation Server Control-used for input verification 1
2. HTML Server Control 1
3.-Web Server Control 2
4. Standard server controls can be divided into the following six types: 2
4.1. (1) standard controls: They mainly refer to traditional Web form controls, such as TextBox, Button, and Panel controls. They have a set of standardized attributes, events, and methods, making development easier. 2
4.2. (2) Data Control: This type of control can be subdivided into two types: Data Source Control and Data Binding control. 3
4.2.1. (3) verification controls: 3
4.3. (4) site navigation controls: 3
4.4. (5) WebParts control: 3
4.5. (6) logon control: 3
1. The server control is a tag that can be understood by the server. There are three types of server controls: 1.1. HTML Server Control-traditional HTML Tag 1.2. Web Server Control-new ASP. NET tag 1.3. Validation Server Control-for input verification
Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://blog.csdn.net/attilax
2. HTML server controls
The HTML server control is an HTML Tag that is understandable to the server.
HTML elements are processed as text.
(1) HTML server controls
The HTML Server Control is derived from the namespace System. Web. UI. HtmlControls. They are converted from common HTML controls (controls defined in the HTML language, such as buttons and Input). The output is basically the same as that of common HTML controls. By default, it is difficult for the server to control common HTML controls on Web pages. However, by converting common HTML controls into HTML server controls, developers can easily control programming.
3.-Web server controls
Web server controls are special labels that are understandable to servers.
Similar to HTML server controls, Web server controls are also created on the server. They also need properties for them to take effect. However, Web server controls do not need to map any existing HTML elements, which represent more complex elements.
ASP. NET standard server controls are defined in the namespace System. Web. UI. WebControls. The so-called "standard" means that such server controls are embedded in the ASP. NET 2.0 Framework and are pre-defined. These controls are not mapped to HTML server controls one by one. They have richer functions and are more abstract than HTML server controls.
4. Standard server controls can be divided into the following six types:
4.1. (1) standard controls: They mainly refer to traditional Web form controls, such as TextBox, Button, and Panel controls. They have a set of standardized attributes, events, and methods, making development easier. 4.2. (2) Data Control: This type of control can be subdivided into two types: Data Source Control and Data Binding control.
The data source control mainly implements data source connection, SQL statement/stored procedure execution, and return dataset combination. Including SqlDataSource, AccessDataSource, XmlDataSource, SiteMapDataSource, and ObjectDataSource. Data Binding controls include Repeater, DataList, GridView, DetailsView, and FormView. These controls are used to display data, provide editing, deletion, and other user interfaces. Generally, you need to use the data source control to connect to the database and return a data set. Then, you can use the data binding control to display, update, and delete data. With the powerful support of Visual Studio 2005, developers can quickly implement the above functions without writing a line of code.
4.2.1. (3) verification controls:
They are a special set of controls that contain verification logic to test user input. These include: RequiredFieldValidator, RangeValiedator, RegularExpressionValidator, and CompareValidator. Developers can append the verification control to the input control to test the content that the user enters into the control. The verification control can be used to check input fields and test against specific values or modes of characters to verify whether a value is within a limited range or other logic.
4.3. (4) site navigation controls:
This type of control can be combined with site navigation data to implement site navigation. Including Menu, SiteMapPath, and TreeView. For large websites, site navigation controls have broad application prospects.
4.4. (5) WebParts control:
Web parts are a great feature that allows you to create Web applications with highly personalized features. The WebParts control is required to implement the Web part function. ASP. NET 2.0 provides the following controls, such as WebPartManager, WebPartZone, EditorZone, CatalogZone, PageCatalogPart, and AppearanceEditorPart.
4.5. (6) logon control:
This type of control can quickly implement user logon and related functions, such as displaying the logon status, restoring the password, and creating new users. Including: LoginView, Login, CreateUserWizard, and LoginStatus.
In Aspnet, how is a server-side control event triggered?
When I was a beginner at ASP. NET, I was impressed by the powerful functions of various controls. Of course, it is also easy to get dizzy. Simply remembering the names of those controls is not a simple task, besides, there are so many attributes, events, functions, and configuration steps ...... haha. Later, I felt that these things were of little value and were rarely used in enterprise-level development. The purpose of writing this article is not to "degrade" or deliberately "exclude" server-side controls in webform. Here we will not discuss the advantages and disadvantages too much. But it is helpful for beginners: in fact, many controls have similar usage. It is relatively easy to use other widgets after mastering one type. For example, it is not difficult to use ListView after using the GridView. Do not "float the control surface", because once you form a certain way of thinking, it will be difficult to improve in the future. Of course, when you understand the nature of the web and the internal mechanisms of these controls, you will find it too simple to look back at those things. This is another question of "Sharpen the knife first or cut firewood first. We often drag a server control to the aspx page (such as a Button), and double-click it to see that a click event is registered in the background code. Alternatively, you can right-click the control and choose Properties From the shortcut menu. Then, locate the lightning icon-event and register the event. This is the "event-driven mechanism" of the legendary webform ". If you have been familiar with VB or windows development, you may feel more comfortable. How are these events triggered? Can I simulate it? Why do I sometimes click the Button without triggering background events? In Asp.net, server events are triggered on the client in two scenarios: 1. in WebControls, the "Button" and "Type" in HtmlControls are "submit" HtmlInputButton ". The two buttons are displayed on the client as follows: <input name = "Submit1" id = "Submit1" type = "submit" value = "Submit"> This is the submit button of the Form. After you click it, it will be sent to the server as a parameter, the parameter is as follows: the name attribute of the control is the value of the control, corresponding to the example above: Submit1 = Submit. The server will know that the button has been clicked based on the key of the received control's name attribute, so that the click event of this button is triggered on the server. II. htmlInputButton with the Type of button in HtmlControls and all other control events, such as LinkButton click and TextBox Change events. After these events are generated on the client, they are sent to the server through a unified mechanism. 1. First, the asp.net page framework uses two den domains to store the events triggered by the control and the event parameters: <! -- Indicates the control that triggers the event, generally the name of the control --> <input type = "hidden" name = "_ EVENTTARGET" value = ""/> <! -- Indicates the parameter used to trigger an event. Generally, when a control has more than two events, used to identify the event --> <input type = "hidden" name = "_ EVENTARGUMENT" value = ""/> 2. the server generates a javascript method to handle the sending of all these events. The code is: <script type = "javascript"> <! -- Function _ doPostBack (eventTarget... the remaining full text>
How to trigger server control events in Aspnet
The server will know that the button has been clicked based on the key of the received control's name attribute, so that the click event of this button is triggered on the server. II. htmlInputButton with the Type of button in HtmlControls and all other control events, such as LinkButton click and TextBox Change events. After these events are generated on the client, they are sent to the server through a unified mechanism. 1. First, the asp.net page framework uses two den domains to store the events triggered by the control and the event parameters: <! -Indicates the control that triggers the event. Generally, the control name --> <input type = "hidden" name = "_ EVENTTARGET" value = ""/> <! -Indicates the parameter used to trigger an event. Generally, when a control has more than two events, used to identify the event --> <input type = "hidden" name = "_ EVENTARGUMENT" value = ""/> 2. the server generates a jscript method to handle the sending of all these events. The code is: <script language = "javascript">
<! -- Function _ doPostBack (eventTarget, eventArgument) {var theform = document. webForm2; theform. _ EVENTTARGET. value = eventTarget; theform. _ EVENTARGUMENT. value = eventArgument; theform. submit () ;}// --> </script> 3. each control that will trigger a server event will call the above Code in the response client event:
For example, in HtmlControls, The Click Event of the HtmlInputButton whose Type is button <! -Call the client's Click Event _ doPostBack. The eventTarget parameter is 'button2', indicating that the event is triggered by the 'button2' control with the name. The eventArgument is empty, the HtmlInputButton with the Type of button has only one server event triggered by the client --> <input language = "javascript" onclick = "_ doPostBack ('button2 ','') "name =" Button2 "id =" Button2 "type =" button "value =" Button "/> another example is the Change event of the TextBox Control. <! -The onchange event of the client calls _ doPostBack. The eventTarget parameter is 'textbox1', indicating the event triggered by the 'textbox1' control, the TextBox Control has only one server event TextChanged triggered by the client, so the server will trigger the TextChanged event of the TextBox-> <I ...... remaining full text>