Response. Write () changes the layout when Div + CSS is laid out.

Source: Internet
Author: User
Recently, I made a project using CSS to control the style. I found that the style changed after response. Write was used, and the position and body were incorrect. Response. this is also true for write ("<SCRIPT> alert (') </SCRIPT>"), which is not found in section 2003 and is hard to understand, I happen to have seen a post on csdn discussing this issue. The reasons are as follows:

Default use in ASP. NET 2.0 <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> document definition model, the rules of this DTD are different from those of the previous, therefore, many previously writtenCodeIt cannot run properly under the new standard.

-----------------------------------------------

Response. Write indicates that data is written at the point of course-output stream.

In ASP. NET, do not randomly use response. Write, which will disrupt the output stream order of ASP. NET.

The output using response. Write in. aspx. CS will appear at the top of the page

The expected page layout will fail.

-------------------------------------------------

Normally, do not use response. Write. it will disrupt your object-oriented model.

------------------------------------------------

Use this instead:

Page. clientscript. registerstartupscript (this. GetType (), "alert", "<SCRIPT> alert ('messagebox effect'); </SCRIPT> ");

Post-Statement: As div is a stream layout, response. the write () Output content is always at the front of the page, breaking the original stream layout, which may cause style changes. However, it is still unclear why the font will change.

 

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.