C# 如何在应用程序中使用静态类在.aspx标记中设置标签文本?

C# 如何在应用程序中使用静态类在.aspx标记中设置标签文本?,c#,asp.net,C#,Asp.net,下面是解决方案中的静态类, 命名空间WebApplication1 { public static class LabelValues { public static string GetLabelValue(string str) { Return "Hello" + str; //There's a complicated logic for this } } } 现在我想用下面的代码设置标签文

下面是解决方案中的静态类, 命名空间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") %>" >


我想从label控件的Text属性调用静态类来设置标签的值

正如VDWWD所提到的,您可以写出完整的名称空间。此外,对于数据绑定语法,我认为您需要将其用单引号括起来

<asp:Label ID="_label1" runat="server" Text='<%# WebApplication1.LabelValues.GetLabelValue("_label1") %>' >

请包含您收到的错误消息。“LabelValue”名称在当前上下文中不存在。您是否已将LabelValue所在的命名空间添加到ASPX页面?请写出完整的命名空间:
WebApplication1.LabelValue.GetLabelValue(“\u label1”)
我认为您必须查看以下内容: