这似乎很有效:
string imagesScript = String.Format(
"MyNamespace.MyClass.prototype.imgDisabled = '{0}';" +
"MyNamespace.MyClass.prototype.imgEnabled = '{1}';",
Page.ClientScript.GetWebResourceUrl(typeof(MyClass), "MyNamespace.disabled.png"),
Page.ClientScript.GetWebResourceUrl(typeof(MyClass), "MyNamespace.enabled.png")
);
Page.ClientScript.RegisterStartupScript(typeof(MyClass), "Images", imagesScript, true);
在我的物品里我只是
this.imgDisabled
或
this.imgEnabled
获取网址。
编辑:
AssemblyInfo.cs
将JavaScript引用设置为
WebResource(..., PerformSubstitution = true)
那么.js文件可以
<%= WebResource("MyNamespace.enabled.png") %>
任何你想去的地方。这可以是您实际使用它或添加到对象原型的位置。