The following is an extract from a javascript file.
Correct string:
url: '<%=ResolveUrl("~/folder/filename.aspx")%>'
How can a variable be inserted within the URL? (As below)
var variable = "filename.aspx"
url: '<%=ResolveUrl("~/folder/" + variable + ")%>'
You can't .
ResolveUrl
is something that is translated to a string on the server side while your variable is a js var.
What you can do is maybe:
var variable = "filename.aspx"
url = '<%=ResolveUrl("~/folder/___MYVAR___")%>' // this will create a /folder/___MYVAR__
url = url.replace('___MYVAR___', variable); // this will create /folder/filename.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.