473,785 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Page.ClientScri pt.RegisterArra yDeclaration

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.ClientScri pt.RegisterArra yDeclaration("m yArray", myArray.ToStrin g())

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

What am I doing wrong here?

Oct 3 '07 #1
2 7169
the RegisterArrayDe claration 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.ClientScri pt.RegisterArra yDeclaration("m yArray","1,2,3" );

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

public string JScriptArrayDec laration(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.ClientScri pt.RegisterArra yDeclaration("m yArray", myArray.ToStrin g())

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

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

"bruce barker" wrote:
the RegisterArrayDe claration 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.ClientScri pt.RegisterArra yDeclaration("m yArray","1,2,3" );

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

public string JScriptArrayDec laration(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.ClientScri pt.RegisterArra yDeclaration("m yArray", myArray.ToStrin g())

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

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
1577
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 info I need to get onto the page. In old asp I would usually do: var someStringValue = "<% = MyStringVar %>"; However everything I try right now has done nothing more than break the page.
6
2246
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 RegisterArrayDeclaration, but I don't see a quick tutorial how. Can anyone post sample C# code-behind-only code on how to do this? Thanks.
9
3209
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 opens as expected. However, when I go back to the original page, all the font sizes are larger. Its as if by clicking on the ImageButton, my CSS formatting was discarded. When I look at the source for the following code, this is what I get:
4
3016
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. here is the javascript produced: <script>window.opener.document.forms.txtEndDate.value = '7/15/2006';self.close()</script> I basically need to populate txtEndDate on the content page. if
4
3326
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 class1 public sub showimg() Dim Response As HttpResponse = HttpContext.Current.Response Dim theImage As New object
2
12392
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 object from within a class? Something like the HttpContext.Current object? My class creates custom scripts that it then adds to the page using Page.ClientScript.IsStartupScriptRegistered and Page.ClientScript.RegisterStartupScript functions.
1
3413
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 I change the type to the working class I can make it work on any page. Works string scriptLocation = Page.ClientScript.GetWebResourceUrl(typeof(FormsBuilderWebPart.FormBuilder), "FormsBuilderWebPart.JScript1.js");
9
42859
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 Update panel and it is working properly. Any solution? Page.ClientScript.RegisterStartupScript(Me.GetType(), "openpopup", "window.open('" & "child.aspx" & "','ChildWindow','height = 520, width = 730,status=no,location=no,directories=no, resizable =...
9
4434
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 dialog box ended up opening up a new browser window with the aspx page, I read on a forum that I should use the iframe control and since I have to open a bunch of pages as diaogboxes, I created a general page(Container.aspx) which has an iframe...
0
9489
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10162
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.