我有一个带有 a Textbox
、 aButton
和一个Label
控件的页面。在 Button_Click 事件中,我将 Textbox 的值存储在后面的variable
调用代码中。S
如何S
使用代码显示标签控件中的值inline
,但不使用code behind
?
我有一个带有 a Textbox
、 aButton
和一个Label
控件的页面。在 Button_Click 事件中,我将 Textbox 的值存储在后面的variable
调用代码中。S
如何S
使用代码显示标签控件中的值inline
,但不使用code behind
?
这不是 ASP.NET 方法,但您可以添加S
为代码隐藏类的成员(至少受保护):
protected string S { get; private set; }
并在页面标记中内联检索它
<%= S %>
我不太确定这个要求,但经过一些修改后它会起作用。将此块嵌入到您的 aspx 页面中:
如果使用 C#
<script runat="server">
void Page_Load(Object sender, EventArgs e)
{
mylabel.Text = s; // Replace with your label control
}
</script>
如果使用 VB.NET:
<script runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
mylabel.Text = s
End Sub
</script>