我的ASP.NET項目調用REST客戶端庫函數,該回調應該調整標籤。但是在調用回調之後,asp標籤不會更改或更新。回調可能嗎?如何在代碼後面的回調函數中更新標籤?
的Default.aspx:
<asp:UpdatePanel runat="server" id="UpdatePanel1">
<ContentTemplate>
<asp:Button OnClick="connect" Text="Connect" runat="server" />
<asp:Label runat="server" Text="Label to be changed" id="Label1">
</asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
Default.aspx.cs:
public void connect(object sender, EventArgs e)
{
Program restCLient = new Program();
restCLient.startConnection(writeToConsole);
}
public void writeToConsole(string str)
{
Label1.Text = str;
}
Programm.cs:
public void startConnection(Action<string> callbackLog)
{
callbackLog("result");
}
你嘗試調試如果writeToConsole被調用? – Sherlock
是的,它被稱爲 – tvelop
你的writeToConsole函數應該在Program.cs中我猜, – Sherlock