简体   繁体   English

在主页上的标签上显示计算机名称

[英]Display Machine name on a label on master page

I have a label on master page on which I want to display the machine name. 我在母版页上有一个标签,要在该标签上显示机器名称。 I am using this but its not working: 我正在使用它,但是不起作用:

<asp:Label ID="Label1" style="font-size: large; color: #009999" runat="server" Text= 'MACHINE NAME IS <%# Environment.MachineName %>' ></asp:Label>  

How to correct it? 如何纠正?

<%# is a data binding expression and will only work where data binding is supported. <%#数据绑定表达式 ,仅在支持数据绑定的情况下有效。 There is no data source for your entire page, therefore the data binding fails. 您整个页面没有数据源,因此数据绑定失败。

You could try just emitting plain old HTML: 您可以尝试仅发出普通的旧HTML:

<span><%= Environment.MachineName %></span>

看起来您正在使用数据绑定标签,而不仅仅是标准的HTML输出标签,请将Text值更改为:

...Text='MACHINE NAME IS <%= Environment.MachineName %>'...

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

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