Previously, we used frame structures for Web pages, but later we met a difficult customer and encountered a problem of switching between frames and non-frame pages. The framework is not required at the beginning, and the framework structure is used for other pages. Click on the homepage of a non-framework structure and refresh the four pages in the framework page on the page. When you switch back the framework, you need to locate the page again. A mean method is used to solve the problem.
In the past few days, we plan to use usercontrol instead of the Framework. Each page's header is dragged with a control. The result is a new big problem. It is mainly about the path.
The file directory structure is as follows.
|
|-[Css]
| -Css.css
|
|-[Images]
| -2.16.gif
| -Background .gif
|
|-[UserControl]
|-Head. ascx
| -.......
|
|-[Module 1]
|-Other. aspx
|
|-Index. aspx
|
Index. aspx:
Call head. ascx
Other. aspx
Call head. ascx
Head. ascx:
<LINK href = "css/css.css" type = "text/css" rel = "stylesheet">
Call head. ascx
<Td background = "images/bar_bg.gif"> <SCRIPT language = "JavaScript" src = "js/fade. js"> </SCRIPT>
<Table>
</Table>
</Td>
<Asp: Image Runat = "server" id = "Image1" ImageUrl = "../images/developer.gif"> </asp: Image>
<Td background = "images/background .gif"> // you cannot solve this path problem.
Question 1:
Now we find that the Image and img are written differently when specifying the Image path.
<Asp: Image ImageUrl = added above ../
Why.
Let's analyze it.
Index. aspx When HTML is finally generated. Head. ascx is actually loaded to the root directory, so the head. ascx and images directories are of the same level.
Img labels use html code directly. So it does not add ../when the image is specified ../
<Asp: image is a server control. If you do not add ../images to it, after the final page is generated. Will generate
Http: // localhost/inf/UserControl/images/developer.gif
Instead
Http: // localhost/inf/images .gif. And <asp: The image is intelligent. It can dynamically adjust the final HTML generated based on the location of the loaded page. Ensure that the image path is good.
Finally, let's give it a try. We found that http: // localhost/inf/index. all images in aspx are normal, while http: // localhost/inf/Module 1/others. in aspx, <asp: Image is displayed normally, while
Problem 1 solution:
A: All images use the Server Control <asp: Image. However, there is no way for those images as the <td cell background
B: or do not divide the directories. All aspx files are thrown to the root directory. (Completely solved. All problems are not problems. But it is the most spam solution, and the entire program directory structure is really bad)
Question 2:
Currently, image problems are basically solved. But I forgot it. There is also a css and js script in head. ascx. Of course, to solve this problem, add the correct path on the page that calls head. ascx.
But now
<Td background = "images/bar_bg.gif"> <SCRIPT language = "JavaScript" src = "js/fade. js"> </SCRIPT>
<Table>
</Table>
</Td>
This section.
This JS script is special. It only serves on the table before <td> </td>. If it is added throughout the page. Then the scope of the function will change.
Posted on let mingyang read (...) Comments (...) EDIT favorites
Refresh comment refresh page Back to Top
Blog homepage blog news flash programmer recruitment Knowledge Base
Copyright 2013 Ambassador Powered by: blog Park template: Hujiang blog