Umschreiben nach Vorschrift JSON Dokumentation

This commit is contained in:
ja
2022-01-10 13:57:12 +01:00
parent d8e7f8acc5
commit 3f7b85ac2b
2 changed files with 67 additions and 74 deletions

View File

@@ -333,9 +333,9 @@
//addNewRow(SDL,Bez,Datguenstig,KartNr) //addNewRow(SDL,Bez,Datguenstig,KartNr)
// Pagemethods.filltable2(<%' =tbl_mainpage %> , SDL, Bez, Datguenstig, KartNr) // Pagemethods.filltable2(<%' =tbl_mainpage %> , SDL, Bez, Datguenstig, KartNr)
//} //}
var data = { var data = {};
"Kennzeichen": id.split(',')[0] data['Kennzeichen'] = id.split(',')[0];
};
$.ajax({ $.ajax({
@@ -343,23 +343,28 @@
url: "LKWs.aspx/filltable2", url: "LKWs.aspx/filltable2",
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
dataType: "json", dataType: "json",
async: true,
data: JSON.stringify(data), data: JSON.stringify(data),
success: function (result) { success: function (data) {
OnSuccess(result.d); result = data.d;
// addheader();
let strHTML = '<tr><th><td>SDL-Nr</td></th><th><td>Bezeichnung</td></th><th><td>Gueltig bis</td></th><th><td>Karten Nummer</td></th></tr>';
alert('Horray! 200 status code!');
// alert(result.rows.length)
$(result).each(function () {
let row = $(this)[0];
strHTML += '<tr><td>' + row["SDL"] + '</td><td>' + row["Bez"] + '</td><td>' + row["Gueltigbis"] + '</td><td>' + row["KartNr"] + '</td></tr>';
alert(row)
$('#<%=tbl_mainpage.ClientID%>').innerHTML = strHTML;
});
}, },
error: function (jqXHR, textStatus, errorThrown) { error: function (jqXHR, textStatus, errorThrown) {
alert("Status:" + jqXHR.status + "\nStatusText: " + textStatus + "\nError:" + errorThrown); alert("Status:" + jqXHR.status + "\nStatusText: " + textStatus + "\nError:" + errorThrown);
} }
}); });
function OnSuccess(result) {
addheader();
alert('Horray! 200 status code!');
alert(result.rows.length)
for (let i = 0; i < result.rows.length; i++) {
let row = $('<tr><td>' + result.rows[i].SDL + '</td><td>' + result.rows[i].Bez + '</td><td>' + result.rows[i].DateGueltig + '</td><td>' + result.rows[i].KartNr + '</td></tr>');
alert(row)
}
}
//filltable2(id.split(',')[0]) //filltable2(id.split(',')[0])
} }
function doPostBack_M(id_M) { function doPostBack_M(id_M) {
@@ -367,7 +372,7 @@
let natplaceholder = document.getElementById('<%=lbl_Placeholder_M.ClientID%>'); let natplaceholder = document.getElementById('<%=lbl_Placeholder_M.ClientID%>');
alert(id_M) alert(id_M)
let table_M = document.getElementById('<%=tbl_mainpage_M.ClientID%>'); let table_M = document.getElementById('<%=tbl_mainpage_M.ClientID%>');
var rowCount = table_M.rows.length; let rowCount = table_M.rows.length;
for (let i = rowCount - 1; i > 0; i--) { for (let i = rowCount - 1; i > 0; i--) {
table_M.deleteRow(i); table_M.deleteRow(i);
@@ -385,32 +390,36 @@
//addNewRow(SDL,Bez,Datguenstig,KartNr) //addNewRow(SDL,Bez,Datguenstig,KartNr)
// Pagemethods.filltable2(<%' =tbl_mainpage_M%> , SDL, Bez, Datguenstig, KartNr) // Pagemethods.filltable2(<%' =tbl_mainpage_M%> , SDL, Bez, Datguenstig, KartNr)
//} //}
var data = { var data_m = {};
"Kennzeichen": id_M.split(',')[0] data_m['Kennzeichen'] = id.split(',')[0];
};
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "LKWs.aspx/filltable2_M", url: "LKWs.aspx/filltable2_M",
contentType: "application/json; charset=utf-8", contentType: "application/json; charset=utf-8",
dataType: "json", dataType: "json",
data: JSON.stringify(data), data: JSON.stringify(data_m),
success: function (result) { async: true,
OnSuccess_M(result.d); success: function (data_m) {
}, result = data_m.d;
error: function (jqXHR, textStatus, errorThrown) { // addheader();
alert("Status:" + jqXHR.status + "\nStatusText: " + textStatus + "\nError:" + errorThrown); let strHTML = '<tr><th><td> SDL-Nr </td></th><th><td> Bezeichnung </td></th><th><td> Gueltig bis</td></th><th><td>Karten Nummer</td></th></tr>';
} alert('Horray! 200 status code!');
$(result).each(function () {
let row = $(this)[0];
strHTML += '<tr><td>' + row["SDL"] + '</td><td>' + row["Bez"] + '</td><td>' + row["Gueltigbis"] + '</td><td>' + row["KartNr"] + '</td></tr>';
alert(row)
$('#<%=tbl_mainpage_M.ClientID%>').innerHTML = strHTML;
});
},
error: function (jqXHR, textStatus, errorThrown) {
alert("Status:" + jqXHR.status + "\nStatusText: " + textStatus + "\nError:" + errorThrown);
}
}); });
function OnSuccess_M(result_M) {
addheader_M();
alert('Horray! 200 status code!');
alert(result_M.rows.length)
for (let i = 0; i < result_M.rows.length; i++) {
let row = $('<tr><td>' + result_M.rows[i].SDL + '</td><td>' + result_M.rows[i].Bez + '</td><td>' + result_M.rows[i].DateGueltig + '</td><td>' + result_M.rows[i].KartNr + '</td></tr>');
alert(row)
}
}
//filltable2(id.split(',')[0]) //filltable2(id.split(',')[0])
} }
</script> </script>

View File

@@ -400,54 +400,38 @@ Partial Class LKWS
<WebMethod> <WebMethod>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> <ScriptMethod(ResponseFormat:=ResponseFormat.Json)>
Public Shared Function filltable2(Kennzeichen As String) As Table Public Shared Function filltable2(Kennzeichen As String) As List(Of Entry)
Dim tbl As Table = New Table Dim list As List(Of Entry) = New List(Of Entry)
tbl.EnableViewState = True
Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen) Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen)
For Each l2 In list2 For Each l2 In list2
Dim tc_SDLNr As TableCell = New TableCell Dim Entrytemp As New Entry
Dim tc_Bezeichnung As TableCell = New TableCell Entrytemp.SDL = l2.SDLNr.ToString
Dim tc_GueltigBis As TableCell = New TableCell Entrytemp.Bez = l2.Kategorie.ToString
Dim tc_KartNr As TableCell = New TableCell Entrytemp.Gueltigbis = l2.GültigBis.ToString
Dim tr As TableRow = New TableRow Entrytemp.KartNr = l2.KartenNr.ToString
list.Add(Entrytemp)
tc_SDLNr.Text = l2.SDLNr.ToString
tc_Bezeichnung.Text = l2.Kategorie.ToString
tc_GueltigBis.Text = l2.GültigBis.ToString
tc_KartNr.Text = l2.KartenNr.ToString
tr.Cells.Add(tc_SDLNr)
tr.Cells.Add(tc_Bezeichnung)
tr.Cells.Add(tc_GueltigBis)
tr.Cells.Add(tc_KartNr)
tr.Attributes.Add("style", "background-color:#ff2500;color:#fff;font-weight:400;")
tbl.Rows.Add(tr)
Next Next
Return tbl Return list
End Function End Function
Public Class Entry
Public SDL As String = String.Empty
Public Bez As String = String.Empty
Public Gueltigbis As String = String.Empty
Public KartNr As String = String.Empty
End Class
<WebMethod> <WebMethod>
<ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)> <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)>
Public Shared Function filltable2_M(Kennzeichen As String) As Table Public Shared Function filltable2_M(Kennzeichen As String) As List(Of Entry)
Dim list As List(Of Entry) = New List(Of Entry)
Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen) Dim list2 As List(Of VERAG_PROG_ALLGEMEIN.cSDL) = VERAG_PROG_ALLGEMEIN.cSDL.GET_LIST_WEB_LKW(401940, Kennzeichen)
Dim Tbl As New Table
Tbl.EnableViewState = True
For Each l2 In list2 For Each l2 In list2
Dim tc_SDLNr As TableCell = New TableCell Dim Entrytemp As New Entry
Dim tc_Bezeichnung As TableCell = New TableCell Entrytemp.SDL = l2.SDLNr.ToString
Dim tc_GueltigBis As TableCell = New TableCell Entrytemp.Bez = l2.Kategorie.ToString
Dim tc_KartNr As TableCell = New TableCell Entrytemp.Gueltigbis = l2.GültigBis.ToString
Dim tr_M As TableRow = New TableRow Entrytemp.KartNr = l2.KartenNr.ToString
list.Add(Entrytemp)
tc_SDLNr.Text = l2.SDLNr.ToString
tc_Bezeichnung.Text = l2.Kategorie.ToString
tc_GueltigBis.Text = l2.GültigBis.ToString
tc_KartNr.Text = l2.KartenNr.ToString
tr_M.Cells.Add(tc_SDLNr)
tr_M.Cells.Add(tc_Bezeichnung)
tr_M.Cells.Add(tc_GueltigBis)
tr_M.Cells.Add(tc_KartNr)
tr_M.Attributes.Add("style", "background-color:#ff2500;color:#fff;font-weight:400;")
Tbl.Rows.Add(tr_M)
Next Next
Return Tbl Return list
End Function End Function
End Class End Class