【发布时间】:2018-08-14 10:49:08
【问题描述】:
下面是解决方案中的静态类, 命名空间 WebApplication1
{
public static class LabelValues
{
public static string GetLabelValue(string str)
{
Return "Hello" + str; //There's a complicated logic for this
}
}
}
现在我想使用下面的代码设置标签文本。但它不起作用
<asp:Label ID="_label1" runat="server" Text="<%# LabelValues.GetLabelValue("_label1") %>" >
我想从标签控件的 Text 属性中调用静态类来设置标签的值。
【问题讨论】:
-
请附上您收到的错误信息。
-
当前上下文中不存在名称“LabelValues”。
-
您是否将 LabelValues 所在的命名空间添加到 ASPX 页面?
-
写出完整的命名空间:
WebApplication1.LabelValues.GetLabelValue("_label1")