我有这个代码:
<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>
...................测试.cs
[System.Web.Services.WebMethod]
private void TimeTest()
{
lblTime.Text = DateTime.Now.ToString();
UpdatePanel1.Update();``
}
当我按下这个按钮时调用 TimeTest 方法:
<id="refreshDocuments">Test</a>
我的问题是:如何更新标签以满足我的需求?
谢谢!