如何使用javascript将javascript数组从一个aspx页传递到另一个aspx页 [英] How to pass a javascript array from one aspx page to another aspx page using javascript
问题描述
你好朋友
我对我有2个aspx页面AddQuote.aspx和AddEvent.aspx
的要求不高
在AddQuote.aspx页面中,我有2个选择列表框和一些控件,可将所有项添加到第二个列表框后从一个列表框添加到另一个列表框,然后单击一个按钮转到AddEvent.aspx页面.在该页面中,我有一个列表框,应该填充在第一页中添加到第二个列表框的项目(AddQuot.aspx).
这是我的要求,我已将第二个列表框项目的列表添加到Array中,并认为要进行另一页加载(AddEvent.aspx),但它显示的数组长度为0(Zero).
我已在AddQuote.aspx按钮单击事件处将添加到选择列表框(在AddEvent.aspx中),但是当我导航到AddEvent.aspx时,由于加载使该列表为空,因此无法看到包含任何项目的列表.但是我该怎么办呢?
我可以使用会话或缓存吗?这是一种好习惯还是我可以实现的任何其他方法?
我正在编写在单独的js文件中添加列表框和Button click事件的代码,并将它们包含在母版页中,并且AddQuote和AddEvent都从母版页继承.
这是我已完成的代码
Hello friends
I have small requirement that I have 2 aspx pages AddQuote.aspx and AddEvent.aspx
in AddQuote.aspx Page I have 2 Select list boxes and some controls to add from one List box to another list box after adding all items to second list box then I click a button to go to AddEvent.aspx page. In that Page I have one list box which I should fill with the items with which I added to second list box in first page(AddQuot.aspx).
this is my requirement, I have added that list of second list box items to an Array and thought to carry to another page load (AddEvent.aspx) but it is showing the array length as 0(Zero).
I have added to the select list box(in AddEvent.aspx) at the AddQuote.aspx button click event but when I navigate to AddEvent.aspx I am unable to see the list with any items because onload the list is made null. But How can I do this?
Can I do with a session or Cache? Is it a good practice or there is any other method that I can implement?
I am writing the code of adding the listbox and Button click event in a seperate js file and I have included them in a master page and both AddQuote and AddEvent are inherited from Master page.
Here is my code that I have done
var i = 0;
if ($("#lstQuoteItems option").length != 0)
{
$("#lstQuoteItems option").each(function ()
{
alert($(this).text());
QuoteItems[i] = $(this).text();
$("#lstAvlQuoteItems").append('<option value="+i+">' + QuoteItems[i] + '</option>');
i = i + 1;
});
alert("Array length " + QuoteItems.length);
window.open("AddEvent.aspx", "_self");
}
else
{
alert("Please Select Quote Items");
}
请任何人告诉我如何解决此问题.
Please any one tell me how to pass from this problem.
推荐答案
(" ).length!=
("#lstQuoteItems option").length != 0) {
(" ).each(功能 () { alert(
("#lstQuoteItems option").each(function () { alert(
( this ).text()); QuoteItems [i] =
(this).text()); QuoteItems[i] =
这篇关于如何使用javascript将javascript数组从一个aspx页传递到另一个aspx页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!