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
- <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
- <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