Getting data in vb.net from dynamic htmlTable

I have an html table that I run at the server level. However, I am having problems accessing the data that it populates.

I populate the table using javascript, but I need to access the data using vb.net.

I am using jquery to retrieve information on a page using a method .html.

Here is my 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);
    }

I am passing information from vb.net using `ArrayList.

Here is my 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>

And here is my 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
+4
source share
3 answers

, JS, ,

,

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

script , , ,

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

post back,

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

,

+2

JavaScript Method , . , .

, , ( -, ), - ().

+1

, TR . , JS, VIEWSTATE, , ASP , POSTBACK, VIEWSTATE. , , projGrid.Rows.Count = 0. , / JS TR VIEWSTATE, , , .

- TR, , , projectGrid.Rows.Count = 1, TR . , TR VIEWSTATE.

, , , JS, , AJAX JSON. JSON, , , , JSON .

+1

All Articles