473,796 Members | 2,740 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 7170
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
3327
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
12393
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
42863
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
4435
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
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
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
10244
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
10021
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
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
7558
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
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
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...
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.