Alternative controls in ASP. NET and ASP. NET

Source: Internet
Author: User

Alternative controls in ASP. NET and ASP. NET

First, let's look at some content in An aspx file:

[Html]View plaincopy
  1. <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <Html xmlns = "http://www.w3.org/1999/xhtml">
  3. <Head id = "Head1" runat = "server">
  4. <Title> </title>
  5. </Head>
  6. <Body>
  7. <Form id = "form1" runat = "server">
  8. </Form>
  9. </Body>
  10. </Html>


We know that ASP. NET will parse this document into a control tree similar to Dom. The control tree is layered and recursive. The top-level Page is the Page. How many controls does the next Page have?

The answer is five. You can verify the value of this. Page. Controls. Count. How is it resolved?

First: from <! DOCTYPE to transitional. dtd "> \ r \ n

Second: from

Third: Include \ r \ n \ <body> \ r \ n \ t after

Fourth: from <form id = to </form>, the type is HtmlForm;

Fifth: From \ r \ n after </form> to the end.

The second and fourth are Html controls, while the first, third, and fifth are static texts. ASP. NET parses them into LiteralControl. LiteralControl is neither a Web control nor an Html control. LiteralControl is a type of control that represents any other strings that do not need to be processed on the server in HTML elements, text, and ASP. NET pages. It can be said that LiteralControl is definitely used in ASP. NET, but you may not know it.

LiteralControl:

1. LiteralControl can also have ID, ClientID, and UniqueID, but it is rarely used. Besides using the FindControl method, setting IDs does not make sense.

2. LitrelControl does not have a view State. Although it also has an EnableViewState attribute, it does not work. The status changed before sending back will be lost.

3. Because it represents static text, you cannot set any style for LitrelControl itself.

4. The background obtains and sets the value through its Text attribute.


One of the most difficult problems in aspnet is to use the File control to upload an alternative File. I don't know how to upload it. I have reference code.

Void f_update (object sender, EventArgs e)
{
String filename = Path. GetFileName (upfile. PostedFile. FileName. ToString ());
Upfile. PostedFile. SaveAs (Server. MapPath ("") + "\" + filename );
}

HTML controls and WEB controls in ASPNET

What do you mean by WEB controls is ASP. NET controls? For example, <ASP: Textbox.../>
HTML controls are designed for compatibility. If you directly use ASP. NET Control, this web page can no longer be edited in other programs, such as Dreamweaver, which is not convenient for the division of labor between web designers and program developers. Some Javascript components are not compatible with ASP. NET controls;

In addition, ASP.net controls consume more or less server resources. These controls are eventually converted to HTML controls by the server. This conversion consumes resources, but this consumption is minimal.
For example, <ASP: Textbox> corresponds to <input type = "text>, <ASP: button> corresponds to <input type =" button "> or <input type =" submit>, <ASP: Label> corresponding <Span>

Therefore, ASP. NET controls can be used as much as possible. They are far more powerful than HTML controls. You can also use the ASP. NET control to upload files.

Dreamweaver is used for design, not programming, and not just ASP.. NET service. Other server-side programming technologies such as PHP and JSP are based on HTML controls, unlike ASP. NET has designed a set of unique controls.

In addition, "one running on the server and one running on the client" is incorrect. Even the HTML control with runat = "server" is also running on the server.

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.