C# 动态填充<;标签文本=";“动态”&燃气轮机;动态</标签>;无法再次检索文本

C# 动态填充<;标签文本=";“动态”&燃气轮机;动态</标签>;无法再次检索文本,c#,asp.net,ajax,C#,Asp.net,Ajax,我正在动态填充label4.text。。我希望检索它,以便在dbms中进行更新 <asp:Label ID="Label4" runat="server" Font-Bold="True" BackColor="#E3EAEB" Height="25px" Width="300px"><%=Application.Get("topic").ToString()%></asp:Label> 在上面的代码中,我需要在标记中插入text=“,但由于语法错

我正在动态填充label4.text。。我希望检索它,以便在dbms中进行更新

<asp:Label ID="Label4" runat="server"  Font-Bold="True" BackColor="#E3EAEB" 
 Height="25px" Width="300px"><%=Application.Get("topic").ToString()%></asp:Label>

在上面的代码中,我需要在
标记中插入
text=“
,但由于语法错误,这是不可能的,或者根本无法完成

我有一个链接按钮,点击链接按钮可以检索标签的文本

<asp:LinkButton ID="LinkButton2" runat="server" Font-Size="Smaller" 
 onclick="LinkButton2_Click">Post to Comment</asp:LinkButton>

protected void LinkButton2_Click(object sender, EventArgs e)
{
    string dumy=Label4.text.toString();
    // This is return a empty string..
}
Post to Comment
受保护的无效链接按钮2\u单击(对象发送者,事件参数e)
{
字符串dumy=Label4.text.toString();
//这是一个空字符串。。
}
请让我知道我哪里做错了…或者有没有其他方法。。。
由于我正在动态填充
标签4.text
。如何检索它?

请在服务器端代码中尝试此操作

    protected override void OnPreRender(System.EventArgs e)
    {
        base.OnPreRender(e);
        if (!IsPostBack)
        {
            Label4.Text = Convert.ToString(Application.Get("topic")); //might be null?
        }
    }
然后,您应该能够从LinkButton中的标签中提取文本(大写“text”)

或者!!您可以直接将dumy字符串设置为应用程序。获取(“主题”)

如果您没有服务器端代码,我只会执行后一个建议,并在页面上创建如下标签:

<label style="font-weight: bold; background: #e3eaeb; height: 25px; width: 300px;"><%=Application.Get("topic").ToString()%></label>


(可能需要查看样式表,只需添加一个class=“mylabelstyle”属性即可您可以使用表达式生成器来完成此操作,我们一直都在这样做

因此,在创建并注册表达式生成器之后,您将执行以下操作

<asp:label runat="server" Text='<%$ AppText : "something" %>' />