Hi
I am using asp.net 2.0 . I have 2 web pages. parentPage.aspx and popuppage.aspx.
I need to transfer all items of the listbox from child page to parentpage listbox. I am using a hidden field in parent page to capture the values.
Also I want to refresh the parentpage so that the parent page listbox items are available on the server side also because I need to push these values into the database.
The code below does populate the parent page listbox with values but values don't persist once the page is refreshed. I know I need to use the "__doPostBack" function of javascript but I am struggling with this. Please help me out.
ParentPage.aspx
--------------------------
popuppage.aspx
--------------------

Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 24, 2008, 10:59 PM EDT
You can get the hidden field value in server side in following way.Use the same lgic for your application
Inline code section:
//declare the fidden field inside body of html
Javascript function.
function LoadFiles(RecordStatus)
{
var LastDays = document.getElementById("txtLastDaysFiles").value; // txtLastDaysFiles is the Id of a text box
document.getElementById("hidlastday").value=LastDays; // assign the lastdays value to hiddenfield
}
codebehind:
private void displayArchiveDetails(Int32 PageNumber)
{
string strLastDays = "";
strLastDays = hidlastday.Value;
}
krishna casukhela18 reputationPosted Aug 26, 2008, 8:42 PM EDT
Hi
I went through ur code. But it isn't working. What is the use of the textbox? After the postback from the child page,
the hidden field(located in parent page) values is lost.
I need to have these values persisted in my parent page.
Can u explain in detail?
thanks
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 26, 2008, 9:19 PM EDT
The concept is simple .I have a text box and I am saving the text box value into hidden field variable inside javascript function.So now this value inside hidden field is available for all the sub pages. You can retrieve the value in 'page load' of any page.
I showed you the concept of hidden field using textbox. You can use any other controls to to do this.
In your case try to retrieve the value of hidden field in page load.
Still if you have any problem then try to access the Hidden variable value in page load of that particular page, where you have declared hidden variable and assign the value in session. Then access it in other pages.
krishna casukhela18 reputationPosted Aug 28, 2008, 9:30 PM EDT
Hi
I was busy of late.
Ok. I got the general idea of what u said. It it's only a single page, then it's fine. But in my case, after the parent page
javascript function executes, the hidden field value(s) are populated into the listbox of parent page. That's fine. But Still I am unable to access this hidden field values at the page_load or a button click of the parent page.
In the parent page
if (page.ispostback)
{
string s = hdnField.value; // Hidden field value is empty at this point
}
I tried taking the values into a textbox. But It doesn't work. And in any case I do not want to use a Session variable
.It defeats the very idea of using a client script.....
Can u suggest a better alternative?
thanks
Niradhip ChakrabortyRank #429 · 5.8K reputationPosted Aug 28, 2008, 10:14 PM EDT
Please modify the code in page load and try it.
if
(!IsPostBack){
string s = hdnField.value; // Hidden field value is empty at this point}
krishna casukhela18 reputationPosted Aug 29, 2008, 4:56 AM EDT
No it doesn't work. values are not present in Hidden field.