CSS files in ASP. NET 2.0

Source: Internet
Author: User

Some people often encounter CSS failures in ASP. NET 2.0 (ASP. NET 1.x may be valid). The main causes and solutions are listed as follows:

1. Incorrect CSS file path

This problem is a basic problem in Web development. Generally, this problem occurs when relative paths are used, or style files are written in the template page, this problem occurs when the content page and template page are not in the same directory. At this point, you need to know the relative path rules in the Web. If you are not clear about the rules, you can try the absolute path method to see if it is a path problem.

2. Incorrect CSS rule writing

No one can help you with this problem. You can only learn CSS-related knowledge by yourself.

3. File Encoding Problems

Sometimes, CSS styles are valid in the aspx file but not in an independent file. If this problem is not caused by path problems, it is caused by encoding problems, you can open the CSS file in notepad, and then save it as ANSI or UTF-8 format.

4. Permission issues

In this case, the style is invalid before logon and is valid only after logon. This is caused by a typical permission problem. This problem occurs only when all files configured in web. config do not allow anonymous access. The solution is to mark and configure the style file to allow anonymous access. For example:

 
 
  1. <Configuration> 
  2. <Location Path="Name of the folder that can be accessed anonymously"> 
  3. <System. web> 
  4. <Authorization> 
  5. <Allow Users="? "/> 
  6. </Authorization> 
  7. </System. web> 
  8. </Location> 
  9. </Configuration> 

5. The button style is invalid.

The most typical cause of this situation is that a statement similar to Response. Write exists in the button event. Because ASP. NET 2.0 adopts HTTP ://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtddocument definition by default, You Need To <! The front of DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> cannot have any output. The solution to this problem is to use ClientScriptManager or Literal control to output content.

6. the style that works in ASP. NET 1.x is invalid in ASP. NET 2.0.

This problem is still caused by xhtml1.

7. The style set by the script is invalid.

Because the xhtml1.DTD requires a unit, you still need to add the unit when setting the value of the object style, such as obj. style. width = "200px ". The following code is invalid in Firefox (do not complain about Firefox troubles)

 
 
  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> 
  4. <Script Type="Text/javascript"> 
  5. //<! [CDATA [ 
  6. Function SetHeight () 
  7. Document. getElementById ("x"). style. height = "200" 
  8. //]> 
  9. </Script> 
  10. </Head> 
  11. <Body> 
  12. <Div Id="X" Style="Background: # DDD; height: auto ;">Test</Div> 
  13. <Input Type="Button" Value="Settings" Onclick="SetHeight ()" /> 
  14. </Body> 
  15. </Html> 


Although the above is normal in IE, problems may occur in Firefox. The correct syntax is as follows:

 
 
  1. document.getElementById("x").style.height="200px" 

The preceding section describes the CSS files in ASP. NET 2.0.

  1. Introduction to ASP. net mvc Framework
  2. Introduction to MvcAjaxPanel in ASP. NET MVC
  3. ASP. net mvc Framework to save UpdatePanel
  4. Use ASP. net mvc source code to find a solution
  5. ActionInvoker of ASP. net mvc Framework

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.