有人能请我指出我在做什么错? 基本上所有我需要的是从我的属性中获取文本,但由于某种原因它总是返回为空。似乎无法从Web窗体中获得<asp:Literal</ asp:Literal>属性
protected void Page_Load(object sender, EventArgs e)
{
orderId.Text = "4567";
}
protected void UpdateOrder(object sender, EventArgs e)
{
var getOrderId = orderId.Text; //always returns null here
}
前端:
<p>
<asp:Label ID="label8" runat="server" AssociatedControlID="orderId"> Order Id: </asp:Label>
<asp:Literal ID="orderId" runat="server"></asp:Literal>
</p> << the orderId is displayed in the browser
<asp:Button ID="updateBtn" runat="server" Text="Update" OnClick="UpdateOrder"/>
我到底做错了什么?
接受你自己的答案,如果可能的话。避免人们查看已回答的问题。 TNX。 – wazz