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:
- <Configuration>
- <Location Path="Name of the folder that can be accessed anonymously">
- <System. web>
- <Authorization>
- <Allow Users="? "/>
- </Authorization>
- </System. web>
- </Location>
- </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)
- <! 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 = "200"
- }
- //]>
- </Script>
- </Head>
- <Body>
- <Div Id="X" Style="Background: # DDD; height: auto ;">Test</Div>
- <Input Type="Button" Value="Settings" Onclick="SetHeight ()" />
- </Body>
- </Html>
Although the above is normal in IE, problems may occur in Firefox. The correct syntax is as follows:
- document.getElementById("x").style.height="200px"
The preceding section describes the CSS files in ASP. NET 2.0.
- Introduction to ASP. net mvc Framework
- Introduction to MvcAjaxPanel in ASP. NET MVC
- ASP. net mvc Framework to save UpdatePanel
- Use ASP. net mvc source code to find a solution
- ActionInvoker of ASP. net mvc Framework