The third day of Asp.net in ten days

Source: Internet
Author: User
Maybe you will ask, why do you need Web controls? The Web Console is like the console in VB. Program All attributes can be referenced and modified anywhere. Code Separated. Think about it. If it is still the previous HTML console, when we need to display the content of a database in a certain place, do we only use <% = %> to include the code block of the program in HTML, the purpose of code separation and interface separation is not achieved.

Maybe you will ask why do you need code separation? The reason is very simple. Not every programmer is a qualified web designer. If we need to modify the code, it will damage the original settings of the web designer. Isn't it inconvenient, the combination of program code and HTML code is not convenient for programmers to modify the code. Of course, our web designers also need to learn a little knowledge about web control.

Here is an introduction:

1. Label control:

Main attributes:

Text displayed by the text Tab

Example: <asp: Label id = "lblmessage" text = "AAA" runat = "server"/>

Note that the runat = "server" cannot be omitted, and all Web controls must be included in the <form runat = "server"> </form>

The following is a complete example. Modify the text attribute of the label in the program to change the display of the webpage.

<SCRIPT runat = "server" Language = "C #">
Void page_load ()
{
Lblmessage. Text = "Hello world! ";
}
</SCRIPT>
<HTML>
<Head> <title> label. aspx </title>
<Body>
<Form runat = "server">
<Asp: Label id = "lblmessage" runat = "server"/>
</Form>
</Body>
</Html>
<SCRIPT runat = "server" Language = "VB">
Sub page_load
Lblmessage. Text = "Hello world! "
End sub
</SCRIPT>
<HTML>
<Head> <title> label. aspx </title>
<Body>
<Form runat = "server">
<Asp: Label id = "lblmessage" runat = "server"/>
</Form>
</Body>
</Html>

2. Textbox Control:

Main attributes:

Text displayed by the text control;

Maximum number of characters that can be added to the maxlength text box (invalid multi-line text box );

Readonly;

Textmode has the following valid values: multiline, password, singleline;

Rows specifies the vertical size of the text box

3. Button control:

There are three types of buttons: Standard Form buttons, form buttons for imagebutton to display images, and linkbutton to display images as hyperlinks.

The button is basically the text attribute to set the text above the button;

Imagebutton is basically the image URL used to set the button image address; alternativetext displays text when the browser does not support images;

The linkbutton is basically the text attribute used to set the text on the button;

The common attribute of the three is causesvalidation = true/false to set whether the form submitted by the button is verified (the validation control will be discussed later)

In common, onclick is the function triggered when a button is clicked. The following is an example:



label. aspx








label. aspx





Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.