"Go" ASP. NET Web site path ~ (wavy line) explanation

Source: Internet
Author: User

Friends who have just started learning ASP. NET may not understand what the ~ symbol in the path represents, such as imageurl= "~/images/sampleimage.jpg"

Now let's see what that means. ~ is the ASP. NET Web application root operator that can be used when you specify a path in a server control. asp. NET resolves the ~ operator to the root directory of the current application. You can use the ~ operators and folders together to specify the path based on the current root directory.

The following example shows the ~ operator that is used to specify the root relative path for an image when using the image server control. In this example, the image file is read directly from the Images folder located in the root directory of the Web application, regardless of where the page is located in the Web site.

[CSharp]View Plaincopy
    1. <asp:image runat="Server" id="Image1" imageurl= "~/images/sampleimage.jpg"/>

You can use the ~ operator in any path-related property in a server control. The ~ operator can be recognized only for server controls and is in server code and cannot be used with the ~ operator for client elements.

Tip: The site root directory in the client element is represented by "/", for example

[CSharp]View Plaincopy
    1. <img src="/images/sampleimage.jpg"/>

This example path assumes that the images folder is located under the Web site root directory.

"Go" ASP. NET Web site path ~ (wavy line) explanation

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.