简体   繁体   English

是否可以通过 Javascript 从动态添加的行中获取 C# 的值?

[英]Is it possible to get values with C# from a dynamically added row with Javascript?

I have a table and rows are added by users by clicking in a button.我有一个表格,用户通过单击按钮添加行。 I do this with Javascript.我用 Javascript 做到这一点。 But then I have to get the values with C# and add then to database.但随后我必须使用 C# 获取值,然后将其添加到数据库中。 C# is mandatory. C# 是强制性的。 How can I do this?我怎样才能做到这一点?

Use AJAX to get/send the values from and to the server.使用AJAX从服务器获取/发送值。

this link would help youjquery此链接将对您有所帮助jquery

Probably the best way to do this would be to use AJAX.可能最好的方法是使用 AJAX。 Since you're already using JavaScript, it would be a simple matter of adding the service call at the finalization stage of the action to implement the database changes directly.由于您已经在使用 JavaScript,因此只需在操作的最终阶段添加服务调用即可直接实现数据库更改。

http://msdn.microsoft.com/en-us/library/aa479042.aspx http://msdn.microsoft.com/en-us/library/aa479042.aspx

you can do it by using jquery & ajax if you dont want you can put all new values in new rows in a hidden field (with a proper structure) and read hidden field value in server side您可以使用 jquery 和 ajax 来实现

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM