Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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.
Posted

1 solution

By client script, you cannot pass a value from one aspx page to another as aspx page runs at server and javascript runs at client's end. To use client script to pass values, you need to persist the value in client side using cookies.

Here are several ways you can pass values,
1. Querystring
2. Cross Page Posting
3. Using Form's POST method to get access of request.forms value to next page
. Hidden fields
5. Session
6. Cache
7. Static object - not desirable
8.Cookies

Using Session will be more resource oriented. Si, I suggest to use cross page posting.
Here is the msdn link,
http://msdn.microsoft.com/en-us/library/ms178139(v=vs.100).aspx[^]

Hope this helps.

cheers
 
Share this answer
 
Comments
Ganesh KP 7-Oct-12 9:36am    
Thanks Sandip, Can we do Cross page posing using Javascript?
Sandip.Nascar 7-Oct-12 9:44am    
No, this can be only done through asp.net pages. Literally cross page posting can only be done in server side.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900