ASP. NET master page references [relative paths] of JS referenced Images

Source: Internet
Author: User
When *. JS is referenced in the master page Relative Path .
1. Use request. applicationpath to obtain the path.


2. use scriptmanager


3. use ~ Symbol pointing to server and path

<Asp: scriptreference Path = "~ /JS/jquery. js "/>
</Scripts>
<Script language = "JavaScript" src = "~ /JS/jquery. js "type =" text/JavaScript "> </SCRIPT>

Method 1: This method can solve the problem of relative paths. We recommend that you use this method.
Method 2: add a lot of useless ASP. Ajax JS references to some pages.
Method 3: "~" It can only be called on the server side. For example, if it is used in a server control, JS cannot be referenced here.

-----------------------

Reference an image on the dashboard page. If you use the control, using the relative path may cause an error.

After the parent page is loaded, the position of the referenced image will change to the relative path relative to the content page. The picture you reference may be wrong!

The reason is that is a client control (Note: other client controls also have the same problem, such as <A> )---

There are two solutions:

1. Use server controls:<Asp: image/>

2.

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.