Home >Web Front-end >HTML Tutorial >(Transfer) When div is laid out with css, response.write() will change the layout_html/css_WEB-ITnose

(Transfer) When div is laid out with css, response.write() will change the layout_html/css_WEB-ITnose

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-24 12:28:241211browse

I recently worked on a project where the style was controlled using CSS. I found that after using response.write, the style changed and the position and font were incorrect. Response.Write("<script>alert(')</script>") is also used in this way. This situation does not exist in 2003. I don't understand it. I happened to see a post on csdn that also discussed this issue. , the reasons mentioned are:

ASP.NET 2.0 uses by default Document Definition Model, the rules of this dtd are different from the previous ones, therefore, many previously written codes cannot run properly under the new standard.

———————————————————————————————————————————————— ------

Response.Write means writing data at the location of the natural output stream

Don’t use Response.Write casually in ASP.NET, it will disrupt ASP.NET Output stream sequence

The output using Response.Write in .aspx.cs will appear at the top of the page

will cause the page layout to not achieve the expected effect

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

Normally don't use response.write, it will disrupt your object-oriented model

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

Use this instead:

Page.ClientScript.RegisterStartupScript (this.GetType(),"alert","<script>alert('messagebox effect');</script>");

Afterword: Since div is a flow layout, response.write ()The output content is always at the front end of the page, breaking the original flow layout, so the style will change, but it is still unclear why the font will also change

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn