如何在页面后面的ASP代码中读取和访问HTML表格

问题描述:

我为发票表单创建了一个jquery动态表,用户可以动态地添加产品,价格,数量和所有数据。我希望这个jquery动态表数据/值在代码后面的文件中。



如何才能实现这一目标?



非常感谢您能在这方面提供帮助。



谢谢

I have created a jquery dynamic table for invoice form on which user can add product,price, quantity and all data's in dynamically. I want this jquery dynamic table data/values in code behind file.

How can i make it possible ?

Much appreciation if you could help in this regards.

Thanks

您必须将数据放入隐藏变量以及屏幕在一张桌子。因此,当您提交表单时,您可以使用jQuery从表中读取数据并将其存储在隐藏字段中,例如:



You'll have to put the data in a hidden variable as well as on the screen in a table. So when you submit the form you could use jQuery to read the data from the table and store it in a hidden field like;

<form id="form1" runat="server">
    <asp:HiddenField ID="MyData" runat="server" />

    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"/>
        
    <script type="text/javascript">


( document )。ready( function (){
(document).ready(function () {


#<%= btnSubmit.ClientID%>)。click(功能(){
// 我很难编码,你可以在添加\删除产品时跟踪此数据
// 或者您可以扫描完成的表并从那里构建它
var myData = {Products:[{ ID 1 名称 产品1},{ ID 1 名称 产品1}]};
("#<%=btnSubmit.ClientID%>").click(function () { // I'm hard-coding this, you can keep a track of this data as you add\remove products // or you can scan the finished table and build it from there var myData = { Products: [{ "ID": 1, "Name": "Product 1" }, { "ID": 1, "Name": "Product 1" }] };