The difference between asp+ and ASP (5)

Source: Internet
Author: User
Tags unique id
How does asp+| differentiate server-side controls from working?
Author: green Apple Computer Studio


How did this happen? The key is to runat= the "server" attribute. To understand how this is done, look at the page in the browser
The source code. That is true:

〈html〉
〈body〉
You selected ' Windows "for Machine ' tizzy '.
〈form name= "ctrl0" method= "post" action= "pageone.aspx" id= "Ctrl0"
〈input type= "hidden" name= "__viewstate" value= "a0z1741688109__x"
Machine Name:
〈input type= "text" id= "txtname" name= "txtname" value= "Tizzy"
〈p/〉
Operating System:
〈select id= "Selopsys" size= "1" name= "Selopsys"
〈option value= "Windows 95" 〉windows 95〈/option〉
〈option selected Value= "Windows 98" 〉windows 98〈/option〉
〈option value= "Windows NT4" 〉windows nt4〈/option〉
〈option value= "Windows 2000" 〉windows 2000〈/option〉
〈/select〉
〈p/〉
〈input type= "Submit" value= "Submit"
〈/form〉
〈/body〉
〈/html〉

Create 〈form〉 with this asp+ code:

〈form runat= "Server"
...
〈/form〉

When the page is executed by asp+, the output to the browser is:

〈form name= "ctrl0" method= "post" action= "pageone.aspx" id= "Ctrl0"
...
〈/form〉

You can see that the action and method properties are created automatically by asp+, so the values that are controlled in the form are mailed back to the same page.
Asp+ also adds a unique ID and name attribute to the form because we do not provide it. But if you do specify these attributes,
The value you specify will be used.

If the method= "get" attribute is included, the contents of the form are sent to the server as part of the query string,
Like previous versions of ASPs, automatic state management is no longer valid.

In the form, create a text box with such asp+ code:

〈input type= "text" id= "txtname" runat= "Server"

The result of the browser is this:

〈input type= "text" id= "txtname" name= "txtname" value= "Tizzy"

You can see that when a form is submitted, asp+ automatically adds the Value property to the text value in control. It still keeps us.
Provides the Name property and adds an id attribute with the same value.

We wrote the following code for the 〈select〉 list:

〈select id= "Selopsys" size= "1" runat= "Server"
〈option〉windows 95〈/option〉
〈option〉windows 98〈/option〉
〈option〉windows nt4〈/option〉
〈option〉windows 2000〈/option〉
〈/select〉

Asp+ is forced to output this HTML, the appropriate 〈option〉 element has a selected attribute:

〈select name= "Selopsys" id= "Selopsys" size= "1"
〈option value= "Windows 95" 〉windows 95〈/option〉
〈option selected Value= "Windows 98" 〉windows 98〈/option〉
〈option value= "Windows NT4" 〉windows nt4〈/option〉
〈option value= "Windows 2000" 〉windows 2000〈/option〉
〈/select〉

Also creates a unique id attribute and automatically adds the matching value attribute to the 〈option〉 element. (If we
Your own Value property is provided on the page and will be retained.

So you can see that there is no magical means of using anything. are standard HTML, no client side script libraries, and
There is no ActiveX control or Java applets. Equally important is that no state is stored on the server at all. Instead
Simply mail the value to the server in a standard way. Before the page is sent to the customer, by request, the value is modified by the server
Control of HTML save and maintain.



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.