Author: Flying
WEB control
I don't think I haven't known how to define this web control for a long time, it is difficult to understand than HTML controls, after all, HTML is too similar to the original Dongdong. The web control is really a lot of access to us, I don't know if you don't remember the words I have said, that is, the program of Asp.net is like a window written in VBVC, first these windows Join our needs of our needs and then operate these controls. If you have learned a little VBVC programming, then understand this is not difficult, the web control in the ASP.NET is like the controls in VBVC. Let's put these controls in the page, then control them through Page_Load and some other custom events. We still take a look at it by watching an example. Let's give a simple Label control. The source code is as follows:
<% @ Page language = "c #"%>
<% @ Import namespace = "system.data"%>
Public void Page_Load (Object SRC, Eventargs E)
{
IF (! page.ispostback)
{
Label3.Text = "This is a black body, and there is an underline";
}
}
script>
hEAD>
bold>
body>
html>
The result after this program is
Test the Label control:
This is the text of red bold
This is a blue slope
This is a black body, and it is underlined
Look at the source code, then look at the result of the program, is it discovered that the Label control and the Label control in VB are very similar :)
(Note: The Chinese you see on your machine may be garbled, then please open the x: /winnt/microsoft/framework/v1.0.224 directory, find the config.Web files, open it, find the following :
RequestentEncoding = "ISO-8859-1" ResponseEncoding = "ISO-8859-1" /> Change the ISO-8859-1 to GB2312, OK, and then execute the program, Chinese is not coming out :) Here we use three ways to operate the Label control, the first is a closed label similar to HTML, writing the words to be written between We have seen the operation of the Label control, then we have a sensibility to the web control. In ASP.NET, there are 28 web controls, which are: Adrotator Button Calendar Checkbox CheckBoxList Comparevalidator CustomValidator DataGrid Datalist DropdownList HyperLink Image ImageButton Label LinkButton Listbox Panel Radiobutton Radiobuttonlist RangevaliDator RegularExpressionValidator RequiredFieldValidator TABLE Tablecell Tablelow TextBox Validationsummary Everyone can go to the site that I am talking about, I will take a look at their respective usage. Here I would like to tell the DataGrid, Datalit, ListBox but they need Binding knowledge (this is in the next section), So we mainly take a look at the use of DropDownList (because we have used SELECT to explain HTML controls) First look at an example: <% @ Page language = "c #"%> <% @ Import namespace = "system.data"%> Public void Page_Load (Object SRC, Eventargs E) { } Public Void Sub_Click (Object Sender, Eventargs E) { String chioce; Chioce = ddl.selectedItem.Text; Show.text = "You choose this studio chiocE " font> member "; } script>
hEAD>