LabelPanel에 LabelParameter가 있고 그 밖에 Button1이 있고 UpdatePanel, Label2 외부에 다른 Label 컨트롤이 있습니다. 버튼을 클릭하면, 나는 레이블 텍스트가 Label1을 업데이트 할 것을 권장합니다UpdatePanel 컨트롤을 사용할 수 없음 - 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
ASPX 페이지
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" AsyncPostBackTimeout="0" />
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
<asp:ContentTemplate>
<asp:Label ID="Label1" runat="server"></asp:Label>
</asp:ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" />
<asp:Label ID="Label2" runat="server"></asp:Label>
</form>
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Label2.Text = "some text";
Label1.Text = "some text";
}
이 솔직해야한다 숨김 코드 버튼 클릭 이벤트로 Label1 텍스트를 업데이트 할 수 있어야합니다. Label2 줄은 성공하지만 (Label1 줄이 "개체 참조가 개체의 인스턴스가 아닙니다"와 함께 실패하는 페이지 다시 게시 없이는 분명히 나타나지 않습니다). Label1이 페이지에있을 때 Label1이 null 인 이유는 그것이 UpdatePanel 안에 있다는 것입니다. Label2와 마찬가지로 페이지에 이미 있어야하고 액세스 할 수있는 컨트롤을 인스턴스화하려면 어떻게해야합니까?
'Label1'의 닫기 태그가 잘못되었습니다. 그냥 오타입니까? (도중에'Label2'와 동일합니다.) – ConnorsFan
@ConnorsFan 예, 수정되었습니다. 다른 컴퓨터에서 수동으로 여기에 모든 것을 입력해야했습니다. – vapcguy
'AsyncPostBackTimeout = "0"'을 제거 할 수 있습니까? – ConnorsFan