473,405 Members | 2,279 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Page.ClientScript.RegisterArrayDeclaration

Hi,
I have a 3 dimenionsal array which I populate in my C# code.

I then want to make this available to my Javascript so I do below.

Page.ClientScript.RegisterArrayDeclaration("myArra y", myArray.ToString())

When I view my source html I see var myArray = new Array(System.Int32[,])

What am I doing wrong here?

Oct 3 '07 #1
2 7144
the RegisterArrayDeclaration is rather stupid and useless. it takes two
parameters, the array name and a string which is the actual javascript
array initialization code. for an int array it wants:
Page.ClientScript.RegisterArrayDeclaration("myArra y","1,2,3");

so you need a helper routine for an int array (air code):

public string JScriptArrayDeclaration(int[] a)
{
string s = "";
string sep = "";
for (int i=0; i < a.Length; ++i)
{
s += sep + a[i].ToString();
sep = ",";
}
return s;
}

-- bruce (sqlwork.com)

C wrote:
Hi,
I have a 3 dimenionsal array which I populate in my C# code.

I then want to make this available to my Javascript so I do below.

Page.ClientScript.RegisterArrayDeclaration("myArra y", myArray.ToString())

When I view my source html I see var myArray = new Array(System.Int32[,])

What am I doing wrong here?
Oct 3 '07 #2
Thanks Bruce.

"bruce barker" wrote:
the RegisterArrayDeclaration is rather stupid and useless. it takes two
parameters, the array name and a string which is the actual javascript
array initialization code. for an int array it wants:
Page.ClientScript.RegisterArrayDeclaration("myArra y","1,2,3");

so you need a helper routine for an int array (air code):

public string JScriptArrayDeclaration(int[] a)
{
string s = "";
string sep = "";
for (int i=0; i < a.Length; ++i)
{
s += sep + a[i].ToString();
sep = ",";
}
return s;
}

-- bruce (sqlwork.com)

C wrote:
Hi,
I have a 3 dimenionsal array which I populate in my C# code.

I then want to make this available to my Javascript so I do below.

Page.ClientScript.RegisterArrayDeclaration("myArra y", myArray.ToString())

When I view my source html I see var myArray = new Array(System.Int32[,])

What am I doing wrong here?
Oct 4 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Kent Ogletree | last post by:
I need to get some JavaScript values onto an aspx page and I am not finding anything using Google. (probably not stumbled onto the right keywords) The code behind has the object that conatins the...
6
by: xenophon | last post by:
I have a grid with checkboxes in it. When a checkbox is un/checked, I want to set a true-false value in an array. Then on PostBack I can work with that array. I know I need to use...
9
by: sck10 | last post by:
Hello, I have a page with an ImageButton that is used to redirect to another page. When the page first opens, everything looks as expected. However, when I click on the image, the new page...
4
by: Mori | last post by:
I am using masterPage and I need to populate a textbox that is in a content control with data from popup page that is not part of the master page. This code works if no masterpage is involved. ...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
2
by: Chris Newald | last post by:
Hello there, I need to be able to call the System.Web.UI.Page object inside a custom class without actually passing the Page object as an argument. Is there an alternate way to access the page...
1
by: Chris Auer | last post by:
I have one page that gets its contents from a class called FormBuilder.cs. It generates a web part. On that page GetWebResourceUrl works fine. All other pages generates an invalid assembly key. If...
9
by: 0301102 | last post by:
I using following script in my project. Once click the button and there will open a pop up window. But "Page.ClientScript.RegisterStartupScript" script seem NOT working in update panel. After remove...
9
by: Bali | last post by:
Default.aspx is the starting page containing a control(ascx) which has asp:button control on it. On the button click event it has to open a new page as a modal control. Since refreshing a page in a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.