Author: Runner from: yesky
The LinkButton component in the ASP.NET's WebForm component is also a server-side component, which is a bit similar to the identifier in the HTML. Its main role is to display a hyperlink in the ASP.NET page. When this link is pressed, the page will pass the information to the server side, and the corresponding event is processed on the server. One. Important composition of the LinkButton component: We explain some common properties, events of the LinkButton component, through the table below.
The common properties of the LinkButton component, the meaning of the event represents text This is a property, which is the text commandName displayed by the LinkButton component. The two properties of Commandargument are basically the same. When the Click event is triggered, it is convenient to pass this two attributes. The server is transmitted to the server. For some of these two properties, some important usages are summarized below. OnClick event is an event when the component is triggered when the component is Click, and is similar to the onClick event above, the difference is that this event is triggered, and the server is passed to the server side, the Commandargument property value.
two. Use the commandName property and the CommandArgument property in the ASP.NET page:
You may have a bit confused in the linkbutton component and the Commandargument property, what will they do. In fact, they have a very important role. For example, as follows:
If there is 100 LinkButton in one of your pages, then it is necessary to determine which linkbutton is pressed. If there is no two properties, you can assign a value by giving each linkButton's text attribute, and then determine which linkbutton is pressed by detecting the text attribute value. Of course, you can also give each LinkButton life different name (of course you are the same name, in the ASP.NET), then in the event handler, by detecting the sender attribute value to determine which linkbutton Pressed. Although these methods are feasible, they are not cumbersome. With the commandName property and the Commandargument property, you can easily solve these problems. Assign the linkButton's commandName property and the Commandargument property to the Commandargument property in the program, and then you can get the data in the COMMANDEventArgs class, so that which linkbutton is pressed until the determination is. So what is the COMMANDEVENTARGS class? The CommandEventArgs class stores the data related to the Button event, and can access these data through the properties of the CommandEventArgs class in the event processing. It is said that when LinkButton is pressed, the data triggered by this LinkButton is stored in the server's CommandEventArgs class, and the properties in the CommandEventArgs class have also accessed the posed LinkButton. In this way, maybe you still have a bit unclear, and below is specifically explained by a program example.
three. Specific use of the LinkButton component:
This article describes how the LinkButton component is described. How the LinkButton component passes the commandName attribute value and the Commandargument property value via an oncommand () event. And how to read the data in the CommandEventArgs class in the program. The LINK.ASPX source code code is as follows:
<% @ Page language = "c #" debug = "true"%>