如何从c#上的动态输入文本框中获取值

时间:2015-04-03 11:29:35

标签: javascript c# html

我在html表格行中创建动态输入文本框,我想在服务器端c#访问它,但是当我访问它时,我得到完整的输入文本框标签而不是它的值。请帮帮我怎样才能得到它 我得到了那样的价值

<input type="text" value="hell" id="hell2" />

脚本

 function addRow() {
        //add a row to the rows collection and get a reference to the newly added row
        var newRow = document.all("ContentPlaceHolder1_tblGrid").insertRow();

        //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes

        var oCell = newRow.insertCell();
        oCell.innerHTML = "<span>Paragraph " + count + "</span>";

        oCell = newRow.insertCell();
        oCell.innerHTML = "<input type='text' class='paraBox' name='t1'>";

        oCell = newRow.insertCell();
        oCell.innerHTML = "<input" +
                          " type='button' value='Add' onclick='addRow();'/>&nbsp;&nbsp;<input" +
                          " type='button' value='Delete' onclick='removeRow(this);'/>";
        count++;
    }

HTML

<table name="tblGrid" id="tblGrid" runat="server">
                        <tr>
                            <td><span>Paragraph</span></td>
                            <td>
                                <input type='text' class="paraBox" name='t1'></td>
                            <td>
                                <input type='button' value='Add' onclick='addRow();' />
                                &nbsp;&nbsp;<input type='button' value='Delete' onclick='removeRow(this);' />
                            </td>

                        </tr>
                    </table>

C#

foreach (System.Web.UI.HtmlControls.HtmlTableRow us in tab.Rows)
    {
        string txt = us.Cells[0].InnerText;           
    }

0 个答案:

没有答案