在服务器端访问html表数据 [英] Accessing html table data in server side

查看:56
本文介绍了在服务器端访问html表数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个想法是在客户端生成一个纯HTML表. (当用户单击按钮时,使用javascript将动态新行添加到表中).这些行包含文本框,下拉列表和其他输入控件.
当用户单击一个按钮时,将触发一个PostBack,其中我需要从服务器端的表访问此数据,对其进行验证并对其执行其他操作.
通过将runat ="server"添加到表标记中,我可以执行客户端并访问服务器端的表数据.但是,我只看到初始表行(而不是通过JavaScript添加的行),并且在从行中检索不同的输入时遇到了麻烦.
任何人都可以在这里帮助我,或向正确的方向发展吗?还是有人为这个问题提供了更好的解决方案?

我正在使用Javascript,Ajax页面方法和回调方法来实现此功能.

谢谢

Hi,

The idea is that a pure html table will be generated on the client side. (using javascript add dynamic new rows to the table when the user clicks a button). These rows contain textboxes, dropdownlists and other input controls.
When the user clicks a button, a PostBack is triggered in which I need to access this data from the table on server side, validate it and perform other actions on it.
I''m able to perform the client side and access the table data on server side by adding runat="server" to the table tag. However, I only see the initial table rows (not the ones added through JavaScript) and I have troubles retrieving the different inputs from the rows.
Can anyone help me out here or put me in the right direction?? Or someone offering a better solution to the problem?

I am using Javascript,Ajax Page Methods and callback methods to implement this..

Thanks

推荐答案



使用隐藏变量保存由javascript动态生成的表.
在转到服务器端之前,请填充隐藏字段(服务器端控件),并在后页代码中对其进行访问.

问候,
Jitendra Zaa
Hi,

Use hidden variable to save the table generated dynamically by javascript.
Before going to server side, populate the hidden field (Server side control) and access it in back page code.

Regards,
Jitendra Zaa


asdf,

为什么不将表放入UpdatePanel并将行添加到服务器端本身.

如果只希望使用javascript,并且还说表仅设置为初始行,请确保在页面加载回发时不要初始化数据或将数据绑定到表.第一次页面加载应将数据填充到表中,而不是在回发时填充以关联客户端数据.
asdf,

Why don''t you put the table in the UpdatePanel and add the rows on server side itself.

If you want in javascript only, and also you said table is set to intial rows only, make sure that you don''t intialize or bind data to table on postback in page load. First time page load should populate data to table but not on postback to pertain the client side data.


这篇关于在服务器端访问html表数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆