When using the user control, many friends may encounter the path of image links and other elements when the user control is placed on pages in different folders! Some friends think that the system domain name is configured in the configuration file, and then the path in the user control is to read the domain name and add the path under the root directory! In ASP. NET, there is a way to get the root directory of the current system! Server Control: <asp: Image id = "Image1" ruant = server ImageUrl = "~ /Images/img1.jpg "/> Html control: '> use this method !~ /Is to get the root directory of the current system! It can be used in all server controls ~ /To get the root directory of the system, and then go down from the root directory! In html, you can use the ResolveUrl function! This is a good solution!
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