私はこのコードを持っています:
<script type="text/javascript" language="javascript">
$(document).ready(function () {
$('#refreshDocuments').click(function () {
var areaId = 42;
$.ajax({
type: "POST",
url: "Test.aspx/TimeTest",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data.d);
}
});
});
});
</script>
...................
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTime" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
....................Test.cs
[System.Web.Services.WebMethod]
private void TimeTest()
{
lblTime.Text = DateTime.Now.ToString();
UpdatePanel1.Update();``
}
このボタンを押すと、TimeTest メソッドが呼び出されます。
<id="refreshDocuments">Test</a>
私の質問は次のとおりです。ニーズに合わせてラベルを更新するにはどうすればよいですか?
ありがとうございました!