The solution of CSS invalidation in asp.net2.0

Source: Internet
Author: User
Tags anonymous relative valid

  People often encounter the problem of CSS invalidation in asp.net 2.0 (asp.net 1.x), the main reasons and solutions are listed below  

1,css file path is not correct this problem is a fundamental issue in web development, generally using a relative path to the problem, or the style file is written in the master page, when the content page and master page is not in the same level of the directory will appear this problem. At this point you have to understand the web of relative path rules, if you do not know, you can use the absolute path of the writing to try to know whether the path of the problem.   2,CSS Rule Writing Error This problem who can not help you, only to learn the relevant knowledge of CSS.   3, File coding problems Sometimes, CSS styles in the ASPX file is valid, but placed in a separate file is not valid, such a problem if not the path problem, it is a coding problem, you can use Notepad to open the CSS file, and then save as ANSI format or UTF-8 format can be.   4, permissions issues The common phenomenon of this situation is that the style is invalid before the login, valid after login, which is a typical permission problem. This problem occurs because Web.config configures all files that do not allow anonymous access, and the workaround is to configure a style file to allow anonymous access for the <location> tag. For example:     code as follows: <configuration>    <location path= "Allow anonymous access to folder name or file path" >       <system.web>          <authorization>           &NBSP ; <allow users= "?" />          </authorization>       </system.web>    < /location> </configuration>     5, click the button style failure The most typical reason is that there are statements like Response.Write in the Click button event, because ASP.net 2.0 by default, the HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD document type definition requires;! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "There is no output in front of >. The solution to this problem is to use the ClientScriptManager output or to use the literal control to output the content.   6, within the ASP.net 1.x the function of the style to the ASP.net 2.0 inside expiration This problem is generally still caused by XHTML1, due to http://www.w3.org/TR/xhtml1/DTD/ XHTML1-TRANSITIONAL.DTD's style rules are different from the previous one, such as adding units, such as width:200; now write width:200px; the solution to this problem is to explicitly add units.   7, script set style is invalid due to XHTML1. DTDs require units, so when you set the value of an object style, you still need to add a unit, such as Obj.style.width = "200px." The following code in Firefox is not valid (don't complain about Firefox trouble)   code as follows: <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <html xmlns=" http://www.w3.org/1999/xhtml "> <head>   <script type=" Text/javascript ">  //<! [cdata[  function setheight ()   {    document.getElementById ("X"). style.height= " } &nbsp ; ]]>   </script> </head> <body> <div id= "x" style= "background: #DDD; height:auto;" > Testing </div> <input type= "button" value= "Settings" onclick= "SetHeight ()"/> </body> </html>     Although the above in IE normal, but in Firefox there will be problems. The correct wording is       code as follows: document.getElementById ("X"). style.height= "200px"  
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.