Webform basics 1: webform Basics

Source: Internet
Author: User

Webform basics 1: webform Basics
WebForm is a product developed by Microsoft. It encapsulates user requests and responses as controls. Let developers think they are operating on a windows interface. This greatly improves the development efficiency. Unlike dreamweaver, you can use code to write a widget or drag it to the page like a winform, and the properties can be changed directly.

 

WinForm is C/S (client)

Mainly local execution

WebForm is B/S (Browser)

It is mainly executed on the server side. The client side mainly sends requests to the server. The server finds the files and sends them to the. net Framework for compilation. After the results are returned, they are sent to the client.

The main flowchart is as follows:

Take a hotel as an example:

To send requests to IIS, IIS is equivalent to a waiter.

Inform kitchen-IIS to inform the. NET Framework of the ASPX you want to see

Kitchen Cooking-. net Framework processes C # code on the ASPX page

Call the waiter to pick up the food-the. NET Framework sends the processed page to IIS, and IIS returns it to the user.

To request a garlic-html page, IIS can directly return the request to the user without going through the. NET Framework.

> Extract data from the database
<% @ Language = "C #" %>
<% @ Import NameSpace = "System. Data. SqlClient" %>
<Html>
<Head> <Body>
<Table border = "1">
<Tr>
<Td> User Name </td>
<Td> password </td>
<Td> nickname </td>
<Td> gender </td>
<Td> birthday </td>
<Td> ethnicity </td>
</Tr>
<%
SqlConnection conn = new SqlConnection ("server = ..; database = lianxi; user = sa; pwd = 123 ");
SqlCommand cmd = conn. CreateCommand ();
Cmd. CommandText = "select * from Users ";
Conn. Open ();
SqlDataReader dr = cmd. ExecuteReader ();
{
%>
<Tr>
<Td> <% = dr [0]. ToString () %> </td>
<Td> <% = dr [1]. ToString () %> </td>
<Td> <% = dr [2]. ToString () %> </td>
<Td> <% = dr [3]. ToString () %> </td>
<Td> <% = dr [4]. ToString () %> </td>
<Td> <% = dr [5]. ToString () %> </td>
</Tr>
</Body>
</Html>

ASP development <%> (Code hitting) <% = %> (used when values need to be assigned inside) <% @ %> (Declaration used)

ASP. NET-. net

WebForm MVC is two technical methods of ASP. NET

WebForm is similar to WinForm for visualized operations

MVC is similar to Java and can be operated with multiple codes.

HTML key points Review

12 form elements:

I. Forms

<Form id = "" name = "" method = "post/get" action = "Server responsible for processing"> IDs cannot be duplicated; names can be repeated; get submission has a length limit, the encoded content is visible in the address bar. There is no length limit for post submission and the encoded content is invisible.

</Form>

1. text input

Text Box <input type = "text" name = "" id = "" value = ""/>

Password box <input type = "password" name = "" id = "" value = ""/>

Text Box <textaarea name = "" id = "" cols = "" (number of characters) rows = "" (several rows high)> </> textarea>

Hide field <input type = "hidden" name = "" id = "" value = ""/>

2. Buttons

Click <input type = "submit" name = "" id = "" disable = "disable" value = ""/> To Go To The submit server address in form.

Reset button <input type = "reset" name = "" id = "disable =" disable "value =" "/>

Normal button <input type = "button" name = "" id = "" disable = "disable" value = ""/>

Image button <input type = "image" name = "" id = "" disable = "disable" value = "" src = "image address"/>

Appendix:

Disable, making the button invalid; enable, make available

3. Select Input

Single button group <input type = "radio" name = "" id = "checked =" checked "value =" "/> the value of name is used for grouping. The value cannot be seen, used to submit to the program; checked, set the default option

Check box group <input type = "checkbox" name = "" id = "checked =" checked "value =" "/>

File Upload <input type = "file" name = "" id = ">

<Label for = ""> </label>

<Label> A tag defines a tag for an input element ).

The label element does not present any special effects to users. However, it improves availability for mouse users. If you click Text in the label element, this control is triggered. That is to say, when the user selects the tag, the browser automatically redirects the focus to the form control related to the tag.

<Label> The for attribute of a tag must be the same as the id attribute of the relevant element.

Drop-down list box

<Select name = "" id = "" size = "" multiple = "multiple"> ------ When size = 1, it is a menu;> 1, it is a list; multiple is multiple.

<Option value = "value"> content 1 </option>

<Option value = "value" selected = "selected"> content 2 </option> ------ seleted, set as default

<Option value = "value"> content 3 </option>

</Select>

 

Control properties:
Label-BackColor and so on will eventually become something in html

Controls will eventually become HTML elements

The layout style still uses HTML + CSS.
Controls are required to replace special data interactions.

The element containing the runat = "server" attribute is the control

 

Related Article

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.