gpt4 book ai didi

javascript - 从动态 htmlTable 在 vb.net 中获取数据

转载 作者:搜寻专家 更新时间:2023-10-31 08:18:00 25 4
gpt4 key购买 nike

我有一个在服务器级别运行的 html 表。但是,我无法访问正在填充的数据。

我正在使用 javascript 填充表,但我需要使用 vb.net 访问数据。

我正在使用 jquery 通过 .html 方法将信息获取到页面。

这是我的javascript,

function ShowProj(strId, qno,ar) {
$('#hiddenQno').val(qno);
$('#qnoLbl').val(qno);
var output = '';
output = "<tr><th>Product</th>";
output += "<th>Bond</th>";
output += "<th>Cut</th>";
output += "<th>Pack</th>";
output += "<th>Delivery date</th></tr>";
for (i = 0; i < ar.length; i++) {
output += "<tr>";
output += "<td style='width: 40%;'>" + ar[i][0] + "</td>";
output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][1] == 1 ? 'checked' : '') + " /></td>";
output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][2] == 1 ? 'checked' : '') + " /></td>";
output += "<td style='width: 10%; text-align: center;'><input type='checkbox' " + (ar[i][3] == 1 ? 'checked' : '') + " /></td>";
output += "<td style='width: 30%;'><input type='text' value='" + ar[i][4] + "'/><input type='hidden' value='" + ar[i][5] + "' /></td>";
output += "</tr>"
}
$('#projGrid').html(output);
}

我正在使用 `ArrayList 从 vb.net 传递信息。

这是我的html,

<div class="modalPopup" id="projPopup" style="width: 40%;">
<table style="width:100%;">
<tr>
<td colspan="2">
<table id="projGrid" runat="server" style="width: 100%;border: 1px solid black; font-size: 16;">
</table>
</td>
</tr>

<tr>
<td>
&nbsp;</td>
<td>
&nbsp;</td>
</tr>
<tr>
<td>
<asp:Button ID="projOk" runat="server" Text="Update" /></td>
<td>
<asp:Button ID="projCncl" runat="server" Text="Cancel" />
</td>
</tr>
</table>
</div>

这是我的 vb.net。

For Each row As HtmlTableRow In projGrid.Rows
'Dim chkBond As HtmlInputCheckBox = row.Cells(1).Controls(0)
Dim str As String
str = row.Cells(0).InnerText
Next

最佳答案

在 JS 中创建的动态行在回发后将无法在服务器上使用,因为它不在 View 状态中要解决此问题,您可以执行以下操作

你可以像这样向页面添加隐藏的输入字段

<input type="hidden" id="hiddenTableData" name="hiddenTableData" value="" />

然后在您的脚本中将您需要的数据添加到隐藏的输入字段中,

$('#hiddenTableData').val(JSON.stringify(ar));

然后在页面回发的服务器上,获取表单隐藏字段的值

String tableData= Request.Form["hiddenTableData"];

解析隐藏字段值,填充你的表并处理它

关于javascript - 从动态 htmlTable 在 vb.net 中获取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26018924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com