如何在asp.net中使用jquery数组,并从asp.net读取数组的值

时间:2022-12-02 10:09:07

I have an array in jquery, and I'm adding values on runtime to this array.After I will access this aray from asp.net page ie: jquery:

我在jquery中有一个数组,我在运行时向这个数组添加值。之后我将从asp.net页面访问这个aray,即:jquery:

var marker=[];
marker[0]='world';
marker[1]='sky';

asp.net:

asp.net:

string []values=new string[];
values[0]=marker[0];
values[1]=marker[1];

how can I do it, is there any way to access jquery veriables from asp.net pages

我怎么能这样做,有没有办法从asp.net页面访问jquery veriables

1 个解决方案

#1


1  

you can store these values in a hidden field and read them in asp.net code behind

您可以将这些值存储在隐藏字段中,并在后面的asp.net代码中读取它们

examples here :

这里的例子:

To get value set in javascript in code behind

在后面的代码中获取javascript中设置的值

Passing value from code-behind to Javascript

将值从代码隐藏传递到Javascript

Edit

编辑

you can pass this array to a WebMethod using ajax post

您可以使用ajax post将此数组传递给WebMethod

JQuery AJAX post to asp.net webmethod never getting called

JQuery AJAX发布到asp.net webmethod永远不会被调用

#1


1  

you can store these values in a hidden field and read them in asp.net code behind

您可以将这些值存储在隐藏字段中,并在后面的asp.net代码中读取它们

examples here :

这里的例子:

To get value set in javascript in code behind

在后面的代码中获取javascript中设置的值

Passing value from code-behind to Javascript

将值从代码隐藏传递到Javascript

Edit

编辑

you can pass this array to a WebMethod using ajax post

您可以使用ajax post将此数组传递给WebMethod

JQuery AJAX post to asp.net webmethod never getting called

JQuery AJAX发布到asp.net webmethod永远不会被调用