473,382 Members | 1,717 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,382 software developers and data experts.

pass array object of child window references from client side to server side

zybernau
hi,

here is my scenario
i am having a array variable in javascript which contains data.
while refreshing or postback these varibles got lost and i did'nt able to get those data in the variables after a refresh/postback

please give me idea how to store back these variable to server before rereshing and taking them back on load


note: i am using asp.net as server side
Thanks,

Raj
Nov 1 '07 #1
18 3581
dmjpro
2,476 2GB
hi,

here is my scenario
i am having a array variable in javascript which contains data.
while refreshing or postback these varibles got lost and i did'nt able to get those data in the variables after a refresh/postback

please give me idea how to store back these variable to server before rereshing and taking them back on load


note: i am using asp.net as server side
Thanks,

Raj
you can do it using Cookie ...... but the problem is you can't store Array in Cookie ..... you have to store it as String

Debasis Jana
Nov 1 '07 #2
you can do it using Cookie ...... but the problem is you can't store Array in Cookie ..... you have to store it as String

Debasis Jana

Thanks JANA ,

but what i am trying is
while onload and onunload the array array object is stored in hdnfield
and on load, its got restored in the javascript
...
window.onload = setChilds("htmHdnChild");

...
<body onunload = "getChilds('htmHdnChild')">


function setChilds(HdnID)
{
alert("in set child");
var hdnCtrl = document.all(HdnID);
if (hdnCtrl!=null)
{
myChild = hdnCtrl;
alert(myChild.length);
}
}

function getChilds(HdnID)
{
//alert("in Get child");
var hdnCtrl = document.all(HdnID);
alert(myChild.length);
hdnCtrl.value = myChild;
alert(hdnCtrl);
}

while setting the array object for the hidden field, its not working for me is there there any other way

Thanks
Nov 1 '07 #3
but what i am trying is
while onload and onunload the array array object is stored in hdnfield
and on load, its got restored in the javascript
...
Expand|Select|Wrap|Line Numbers
  1. window.onload = setChilds("htmHdnChild");
...
[HTML]<body onunload = "getChilds('htmHdnChild')">[/HTML]


Expand|Select|Wrap|Line Numbers
  1. function setChilds(HdnID)
  2. {
  3. alert("in set child");
  4. var hdnCtrl = document.all(HdnID);
  5. if (hdnCtrl!=null)
  6. {
  7. myChild = hdnCtrl;
  8. alert(myChild.length);
  9. }
  10. }
  11.  
  12. function getChilds(HdnID)
  13. {
  14. //alert("in Get child");
  15. var hdnCtrl = document.all(HdnID);
  16. alert(myChild.length);
  17. hdnCtrl.value = myChild;
  18. alert(hdnCtrl);
  19. }
  20.  
while setting the array object for the hidden field, its not working for me is there there any other way
Nov 1 '07 #4
dmjpro
2,476 2GB
Thanks JANA ,

but what i am trying is
while onload and onunload the array array object is stored in hdnfield
and on load, its got restored in the javascript
...
window.onload = setChilds("htmHdnChild");

...
<body onunload = "getChilds('htmHdnChild')">


function setChilds(HdnID)
{
alert("in set child");
var hdnCtrl = document.all(HdnID);
if (hdnCtrl!=null)
{
myChild = hdnCtrl;
alert(myChild.length);
}
}

function getChilds(HdnID)
{
//alert("in Get child");
var hdnCtrl = document.all(HdnID);
alert(myChild.length);
hdnCtrl.value = myChild;
alert(hdnCtrl);
}

while setting the array object for the hidden field, its not working for me is there there any other way

Thanks
How can you assign an array to a hidden field?
It is not possible.
You can store the values in a hidden field something like this.

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" id = "hdnID">
  2.  
Expand|Select|Wrap|Line Numbers
  1. var hdn = document.getElementById('hdnID');
  2. var array_values = "";
  3. var separator = "/*the separator character so that it does not occur in your array values*/";
  4. var array_obj = /*this is your array object*/ ;
  5. for(var i = 0;i<array_obj.length-1;i++) array_values += array_obj[i] + separator;
  6. array_values += array_obj[i];
  7. /*now write a code for retrieving the values from your hidden field ...using String.split method*/
  8.  
Debasis
Nov 1 '07 #5
dmjpro
2,476 2GB
but what i am trying is
while onload and onunload the array array object is stored in hdnfield
and on load, its got restored in the javascript
...
window.onload = setChilds("htmHdnChild");

...
<body onunload = "getChilds('htmHdnChild')">


function setChilds(HdnID)
{
alert("in set child");
var hdnCtrl = document.all(HdnID);
if (hdnCtrl!=null)
{
myChild = hdnCtrl;
alert(myChild.length);
}
}

function getChilds(HdnID)
{
//alert("in Get child");
var hdnCtrl = document.all(HdnID);
alert(myChild.length);
hdnCtrl.value = myChild;
alert(hdnCtrl);
}

while setting the array object for the hidden field, its not working for me is there there any other way
Don't do post double and try to use code tags before post.

debasis
Nov 1 '07 #6
How can you assign an array to a hidden field?
It is not possible.
You can store the values in a hidden field something like this.

Expand|Select|Wrap|Line Numbers
  1. <input type="hidden" id = "hdnID">
  2.  
Expand|Select|Wrap|Line Numbers
  1. var hdn = document.getElementById('hdnID');
  2. var array_values = "";
  3. var separator = "/*the separator character so that it does not occur in your array values*/";
  4. var array_obj = /*this is your array object*/ ;
  5. for(var i = 0;i<array_obj.length-1;i++) array_values += array_obj[i] + separator;
  6. array_values += array_obj[i];
  7. /*now write a code for retrieving the values from your hidden field ...using String.split method*/
  8.  
Debasis


Thanks Debasis,

is there any replacement for the hidden field that can store array variable
in server
Nov 1 '07 #7
dmjpro
2,476 2GB
Thanks Debasis,

is there any replacement for the hidden field that can store array variable
in server
hey are you looking for server side script ...?
but you have first send it to ..... server ............then you can store it.
i think you can't directly send an array to server.

debasis
Nov 1 '07 #8
hey are you looking for server side script ...?
but you have first send it to ..... server ............then you can store it.
i think you can't directly send an array to server.

debasis
that is what i am asking man, what we will do for text, we will store in the a hidden field and read the same in the server side, store in a session variable and retrive the same in some where in other pages or the same postback page

here what i need to know is there any thing replacement for hidden field
to store array objects..


Thanks
Nov 1 '07 #9
acoder
16,027 Expert Mod 8TB
Threads merged. Please do not double post.
Nov 1 '07 #10
Dear All,

i am having a parent window
say parent.aspx
here i am creating child windows in javascript
like this
Expand|Select|Wrap|Line Numbers
  1. var myChild = new Array();
  2.  
  3. function MenuPopUp(url,width,height,left,top)
  4.     {
  5.         if (width == 0)//code to close all the open windows
  6.         {
  7.  
  8.             var len=0;
  9.             for (i=0; i<myChild.length; i++) 
  10.                 {
  11.                 if (myChild[i].closed == false)
  12.                     len = len+1;
  13.                     //alert(myChild[i])
  14.                 }
  15.             //alert(len);
  16.  
  17.             if (len >0) {
  18.  
  19.             if (len == 1)
  20.             {
  21.                 alert(" Switch from Company - Closing the open Window ")    ;
  22.             }
  23.             else
  24.             {
  25.                 alert(" Switch from Company - Closing all "+ len +" open Windows ")    ;
  26.             }
  27.  
  28.             for (i=0; i<len; i++) 
  29.                 {
  30.                 if (myChild[i].closed == false)
  31.                 myChild[i].close();
  32.                 }
  33.             }
  34.             relocate(url,"s_company_name");
  35.  
  36.         }
  37.         else// code open newe window and assign to the array 
  38.         {
  39.             var Children ;
  40.             Children = myChild.length;
  41.             //alert(Children);
  42.             myChild[Children] = window.open(url,"","width=" + width +",height=" + height +",top=" + top + ",left=" + left + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no");
  43.         }
  44.     }
  45.  
this function will open a new window in else part and closes the existing windows in the if part

and for each window i am opening i am referencing/assigning it[window] to a array object

so while doing some action in the main page , i need to close the child windows , so i can directly close by looping though the array and close the windows.

but in my main page [parent] page i have implemented a page refreshing logic
according to this the page will refresh after 500 secs

so in this following scenario the certain open windows become orphan
1) opening 2 new windows at 10th sec
2) wait until the page refreshes [say 500]
3) after 500 sec open another window
4) now do the task where you need to close all the child windows
5) the already opened 2 windows left open as orphans

this is why because while refreshing the javascript variable [myChild] is being reset and all the values contained in the variable is destroyed.

the windows opened will have no reference

Question:
so now i need to pass this array object to server[on unload event] and save the object in the session variable and retrive and restoring it to the array variable while the page loads again
so i may be having reference to all the child windows opened..

please give me solution

Thanks,
Raj
Nov 2 '07 #11
gits
5,390 Expert Mod 4TB
hi ...

i think that will not work the way you think, i'm quite sure that you cannot store window-references at the server since that are client-side objects ... but you have other possibilities:

1. instead of refreshing the entire page you may use an ajax-call and update only the relevant parts of your page

2. use a frameset with a frame for your main page and one with 0px height and width, where you may store your references during the app-runtime

kind regards
Nov 2 '07 #12
acoder
16,027 Expert Mod 8TB
but what i am trying is
while onload and onunload the array array object is stored in hdnfield
and on load, its got restored in the javascript
...
[snip]
while setting the array object for the hidden field, its not working for me is there there any other way
Use the Array object's join() method.
Nov 2 '07 #13
hi ...

i think that will not work the way you think, i'm quite sure that you cannot store window-references at the server since that are client-side objects ... but you have other possibilities:

1. instead of refreshing the entire page you may use an ajax-call and update only the relevant parts of your page

2. use a frameset with a frame for your main page and one with 0px height and width, where you may store your references during the app-runtime

kind regards

Thanks gits,
so there is no way for passing the array objects from client side to server side
Nov 2 '07 #14
Use the Array object's join() method.


please see this
link ...
Nov 2 '07 #15
acoder
16,027 Expert Mod 8TB
Since the threads are dealing with the same problem, I've merged the threads.
Nov 2 '07 #16
acoder
16,027 Expert Mod 8TB
Thanks gits,
so there is no way for passing the array objects from client side to server side
Normal arrays with simple data such as numbers and strings, yes, but references to child windows, no.

Why not use Ajax, frames or iframes as gits has suggested?
Nov 2 '07 #17
Normal arrays with simple data such as numbers and strings, yes, but references to child windows, no.

Why not use Ajax, frames or iframes as gits has suggested?
Thanks moderator

i don't know ajax or sorta please refer me some posts, so that i can start with .. Thanks
Nov 3 '07 #18
acoder
16,027 Expert Mod 8TB
See this example and also check out the tutorials in the Offsite Links thread.
Nov 3 '07 #19

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Randell D. | last post by:
Folks, I'm working on a contact name/address database whereby a slimed down list is shown in the main window. When a record is selected, the complete record is displayed in a new window via a...
3
by: Isabel | last post by:
How can you close all child browser windows that where open by a parent browser window? I have links on a parent (main) page that opens the child page as a separate browser. However, I need to be...
2
by: Augusto Cesar | last post by:
Hello people. How can I Pass ASP Array variable to Javascript; I´m to trying this: <script language="JavaScript"> var x = new Array(10);
3
by: Chris | last post by:
I have a modal (yes it must be modal) web page. I do this by having an empty frame that points to my main page (so that I can repost without new popups) I have to pass data to the child page from...
9
by: kermit | last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or Javascript on an aspx page. I added a refrence to the scrrun.dll I added importing namespaces for 'System.Object',...
10
by: Sean Dockery | last post by:
I have the following HTML file that I've been using for testing... <html> <head> <script type="text/javascript"> <!-- function handleWindowLoad() { var items = ; for (var i = 0; i < 11; i++)...
2
by: gialby | last post by:
Ciao i have this problem.... i have a main asp page with this code PARENT PAGE <script language="vbScript"> function ricerca() ...
7
by: multicherry | last post by:
Hi, Having searched for a way to fetch a window object by name, all I came across were answers along the line of... "All you have to do is say windowObj = window.open("blah", "name");" which...
1
by: John L. | last post by:
How do I invoke the scroll() method of a window object for a scrollable IFRAME element in an HTML document? I am using IE 7.0, and I thought the following would work: ...
3
Frinavale
by: Frinavale | last post by:
I've created a few ASP.NET Ajax Enable Server controls. There are 2 components to these controls: a server side Object that deals with the server side stuffs, and a client side Object that deals...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.