将字符串从服务器传递到客户端javascript [英] passing a string from the server to client side javascript

查看:65
本文介绍了将字符串从服务器传递到客户端javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个ASP.NET网站,其中一个页面包含javascript,这是一个

检查数据网格中的任何数据是否已更改。我的问题是它在填充数据网格后需要花费大量时间在javascript

中填充数组。


我想要做的是在

服务器端(.vb)创建一个逗号分隔的字符串,然后让javascript通过array()获取它....


我想弄清楚我的问题是如何将服务器端函数中创建的字符串

传递回客户端,以便javascript

函数可以读取它并填充一个数组。


有没有人有任何指示如何做到这一点?


谢谢你,

Lyners

Hello all,
I have an ASP.NET website where one of my pages contain javascript that is a
check to see if anydata within a datagrid has changed. My problem is that it
takes a considerable amount of time to populate the array in the javascript
after the datagrid is populated.

What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through array()....

My problem that I am trying to figure out is how do I pass a string that is
created in a server side function back to the client so that a javascript
function could read it and populate an array.

Does anybody have any pointers how to do this?

Thank you,
Lyners

推荐答案

准备commans分隔的字符串,然后用JS块写入它br />
RegisterclientScriptBlock种方法。然后有另一个JS函数

实现了这个字符串并填充你所用的元素

填充。


" Lyners" < Ly的**** @ discussions.microsoft.com>在消息中写道

新闻:DF ********************************** @ microsof t.com ...
Prepare the commans separated string and then write it in JS block using
RegisterclientScriptBlock kind of methods. And then have another JS function
implementted that picks up this string and populate what ever you are
populating.

"Lyners" <Ly****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
大家好,我有一个ASP.NET网站,其中一个页面包含javascript

检查是否数据网格中的anydata已更改。我的问题是,在填充数据网格后,
它需要花费相当多的时间来填充数组中的数组。

我是什么我正在考虑做的是在服务器端(.vb)创建一个逗号分隔的字符串,然后让javascript通过
array()来获取....

我想弄清楚我的问题是如何将在服务器端函数中创建的字符串传递回客户端,以便javascript
函数可以读取它并填充一个数组。

有没有人有任何指示如何做到这一点?

谢谢你,
Lyners
Hello all,
I have an ASP.NET website where one of my pages contain javascript that is
a
check to see if anydata within a datagrid has changed. My problem is that
it
takes a considerable amount of time to populate the array in the
javascript
after the datagrid is populated.

What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through
array()....

My problem that I am trying to figure out is how do I pass a string that
is
created in a server side function back to the client so that a javascript
function could read it and populate an array.

Does anybody have any pointers how to do this?

Thank you,
Lyners



在你的aspx文件中:


<%#MyString%>


在VB文件中:

受保护的MyString为字符串=" m,y,s,t,r,i,n,g"


希望这会对你有所帮助


" Lyners" < Ly的**** @ discussions.microsoft.com>在消息中写道

新闻:DF ********************************** @ microsof t.com ...
In your aspx file:

<%# MyString%>

In your VB-file:
Protected MyString as string = "m,y,s,t,r,i,n,g"

Hope this helps you

"Lyners" <Ly****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
大家好,我有一个ASP.NET网站,其中一个页面包含javascript

检查是否数据网格中的anydata已更改。我的问题是,在填充数据网格后,
它需要花费相当多的时间来填充数组中的数组。

我是什么我正在考虑做的是在服务器端(.vb)创建一个逗号分隔的字符串,然后让javascript通过
array()来获取....

我想弄清楚我的问题是如何将在服务器端函数中创建的字符串传递回客户端,以便javascript
函数可以读取它并填充一个数组。

有没有人有任何指示如何做到这一点?

谢谢你,
Lyners
Hello all,
I have an ASP.NET website where one of my pages contain javascript that is
a
check to see if anydata within a datagrid has changed. My problem is that
it
takes a considerable amount of time to populate the array in the
javascript
after the datagrid is populated.

What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through
array()....

My problem that I am trying to figure out is how do I pass a string that
is
created in a server side function back to the client so that a javascript
function could read it and populate an array.

Does anybody have any pointers how to do this?

Thank you,
Lyners



谢谢Maarten,但我的字符串一直空着。我在评论之前有一个类似的设置

,我将Public字符串更改为受保护的字符串,但

仍然没有骰子。


这是我的声明和我创建字符串的声明:


受保护的strIds As String =" Start"


In我的循环我做了以下几点;


dblRecordCounter = dblRecordCounter + 1

strIds = strIds& "," &安培; " MyDataGrid__ctl" + str(dblRecordCounter

+ 2)+" _txtField"


在aspx文件中我有这个;

ServerString = new String(''<%#strIds%>'');

var ids = ServerString.split('','');


但是ids [0]或1,2,3,4,5 ....是空白的


我知道我遗漏了一些简单的东西。你能看到吗?


谢谢你,

Lyner

" Maarten"写道:
Thanks Maarten, but my string keeps coming back empty. I had a simular setup
prior to your comment, I changed the Public string to a protected string, but
still no dice.

Here is my declaration and my statement that is creating the string:

Protected strIds As String = "Start"

In my loop I do the following;

dblRecordCounter = dblRecordCounter + 1
strIds = strIds & "," & "MyDataGrid__ctl" + Str(dblRecordCounter
+ 2) + "_txtField"

In the aspx file I have this;
ServerString = new String(''<%# strIds%>'');
var ids = ServerString.split('','');

but ids[0] or 1,2,3,4,5.... is blank

I know I am missing something simple. Can you see it?

Thank you,
Lyner
"Maarten" wrote:
在您的aspx文件中:

<%#MyString%>

在您的VB文件中:
受保护的MyString为string =" m,y,s,t,r,i,n,g"

希望这可以帮助你

Lyners < Ly的**** @ discussions.microsoft.com>在消息中写道
新闻:DF ********************************** @ microsof t.com。 ..
In your aspx file:

<%# MyString%>

In your VB-file:
Protected MyString as string = "m,y,s,t,r,i,n,g"

Hope this helps you

"Lyners" <Ly****@discussions.microsoft.com> wrote in message
news:DF**********************************@microsof t.com...
大家好,我有一个ASP.NET网站,其中一个页面包含javascript
a
检查数据网格中是否有任何数据已经改变。我的问题是,在填充数据网格后,
它需要花费相当多的时间来填充数组中的数组。

我是什么我正在考虑做的是在服务器端(.vb)创建一个逗号分隔的字符串,然后让javascript通过
array()来获取....

我想弄清楚我的问题是如何将在服务器端函数中创建的字符串传递回客户端,以便javascript
函数可以读取它并填充一个数组。

有没有人有任何指示如何做到这一点?

谢谢你,
Lyners
Hello all,
I have an ASP.NET website where one of my pages contain javascript that is
a
check to see if anydata within a datagrid has changed. My problem is that
it
takes a considerable amount of time to populate the array in the
javascript
after the datagrid is populated.

What I am thinking of doing is creating a comma delimited string on the
server side (.vb) and then have the javascript pick it up through
array()....

My problem that I am trying to figure out is how do I pass a string that
is
created in a server side function back to the client so that a javascript
function could read it and populate an array.

Does anybody have any pointers how to do this?

Thank you,
Lyners




这篇关于将字符串从服务器传递到客户端javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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