Generally speaking, there are three ways to express link paths: absolute paths, relative paths, and root-based paths. In addition, for ASP.NET server controls, you can also use "~" to represent the root directory.
In MasterPage and user controls, some pictures are often used as backgrounds or beautiful buttons. However, when specifying the src or background of the picture, errors often occur due to link path problems.
1. Use absolute paths: It is generally not advisable to use absolute file paths in the form of "D:xxxxxx.gif". You can consider using the URL method and write it as http://www.xxx.net . If one day the site needs to be updated , how should we deal with making the pictures visible during design? I used CSS to make this work. For elements and controls that want to display images, we can write a simple piece of css to locate the image. Because the location of the css file generally does not change (located in App_Theme/themename/xxx.css), this method is effective. .
.HideBar
{
height:56px;
width:5px;
cursor:hand;
background-image: url(../../images/xxx.gif);
}Next, we only need to fill in HideBar in the cssclass of the corresponding elements and controls, so that every page that inherits MasterPage or uses user controls can display images correctly.
I think there should be other better ways, and I hope someone can give some advice.
——Robin Lu's Blog