简体   繁体   English

VB.Net-HTML属性中的属性

[英]VB.Net - Properties in HTML attributes

I'm attempting to insert a base url property into some attributes for a .Net master page that I'm building. 我正在尝试将基本url属性插入正在构建的.Net母版页的某些属性中。

The purpose of this attribute insertion is to make sure that I need only change a single value in a config file to change the head portion of a url, thus saving time when I'm moving my program between different servers. 插入此属性的目的是确保只需要更改配置文件中的单个值即可更改url的开头部分,从而节省了在不同服务器之间移动程序时的时间。

On the code-behind of the master page I have an exposed property 'baseUrl' that stores the current base location path of the running program. 在母版页的代码后面,我有一个公开的属性'baseUrl',该属性存储正在运行的程序的当前基本位置路径。

When I attempt to add my property into a script tag it looks like this: 当我尝试将属性添加到脚本标签中时,它看起来像这样:

<script type="text/javascript" src="<%# strBaseUrl %>/Javascript/Script.js"></script>

This will tend to work with the path changing based on a value I've set elsewhere in config. 这将有助于根据我在config中其他位置设置的值更改路径。

However using the property in a similar way for CSS doesn't tend to work: 但是,以类似方式将属性用于CSS却无法正常工作:

<link rel="stylesheet" href="<%# strBaseUrl %>/Style/StyleSheets/foundation.min.css">

Instead the string appended before the url doesn't reflect the contents of the 'strBaseUrl' variable and just appears as a set of periods and precentage symbols. 而是在url前面附加的字符串不能反映'strBaseUrl'变量的内容,而只是显示为一组句点和百分比符号。

Does anyone know a correct means of concatenating the baseUrl into an HTML attribute for this purpose, that works with the link tag (ie CSS)? 有没有人知道将baseUrl连接到HTML属性的正确方法,该方法可与链接标记(即CSS)一起使用?

这应该工作

   <script type="text/javascript" src="<%=strBaseUrl%>/Javascript/Script.js"></script> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM