0
我嘗試通過使用腳本更新標籤。在腳本之後,每個Label.value已經有數據,但它不在頁面上更新。這裏是我的代碼:ASP。 NET標籤不更新與jQuery的ajax/POST
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "a", @" <script type='text/javascript'>
function bbfb() {
$.ajax({
type: 'POST',
url: 'ImgService.asmx/GetAllImgs',
data: '{}',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
async: false,
success: function (msg) {
var cars = msg.d;
var TextBoxError = document.getElementById('Labelxyz123');
var TextBoxError1 = document.getElementById('LabelLogContent');
TextBoxError.value = cars;
TextBoxError1.value = cars;
},
failure: function (msg) {
alert('fail');
}
});
}
function BindEvents() {
setTimeout(function() {
bbfb();
//At this point, all of the labels already have data
var TextBoxError = document.getElementById('Labelxyz123');
var TextBoxError1 = document.getElementById('LabelLogContent');
alert(TextBoxError.value);
alert(TextBoxError1.value);
//
}, 0);
}
BindEvents();
</script>", false);
UpdatePanelEdit_on.Update();
這裏是我的ASP代碼:
<asp:Label ID="Labelxyz123" runat="server" ClientIDMode="Static" Text="a"></asp:Label>
<asp:UpdatePanel ID="UpdatePanelEdit_on" runat="server" UpdateMode="Conditional"
ChildrenAsTriggers="false">
<ContentTemplate>
<asp:Label ID="LabelLogContent" ClientIDMode="Static" runat="server" Text="a"></asp:Label>
</ContentTemplate>
<Triggers>
</Triggers>
</asp:UpdatePanel>
兩個標籤內外更新面板並沒有更新。