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

Transfer Date from one page to another in aspx

112 100+
I have two page one is parent and child. Parent page has text field and command button. The Link button open a child page as a popup. Child page as Text box and Button. when i click the button it will transfer child textbox data parent page text box. this is working fine when i use normal page(Not using master page on it).
Parent page aspx:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
  3. <a href="#" onclick="OpenNewWindow()">Lookup</a>
  4.  
  5.  
  6. function OpenNewWindow() 
  7. {
  8. window.open('Child.aspx','MyPopUp','width=500,height=700,scrollbars=1,resizable=1');
  9. }
  10.  
Child.aspx:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  3. <input id="Button2" onclick="Transfer()" type="button" value="Select" style="width: 65px" />
  4.  
  5. function Transfer() 
  6. {
  7. window.opener.form1.TextBox1.value = document.getElementById("TextBox1").value; 
  8. window.close(); 
  9. }
  10.  
This code is working fine. Child page transfer the data parent.

But i when i use master page in parent page. I can open child page using pop up. The child page not transfering the data to parent page with same code. i dont know whats went wrong. Can i anybody what i have to change. I am not getting any error and the data is not transfering

Thanks in advance
May 27 '08 #1
21 3916
DrBunchman
979 Expert 512MB
Hi imtmub,

If you check the source html generated by your code you'll probably find that the ID of TextBox1 has been changed to something like ctl00_Content1_TextBox1.

To get the actual ID you need to pass the ClientID property of your TextBox control to your popup window and use that to pass the value back. Here's an example:

Parent:
Expand|Select|Wrap|Line Numbers
  1. window.open('Child.aspx?txt=<%=TextBox1.ClientID%>','MyPopUp','width=500,height=700,scrollbars=1,resizable=1');
Child:
Expand|Select|Wrap|Line Numbers
  1. window.opener.form1.TextBox1.value = document.getElementById('" & Request.Querystring("txt") & "').value; 
Let me know how you get on,

Dr B

PS You posted this in the ASP Forum which is for Classic ASP only - I've moved it for you but please remember to post all future ASP.NET questions in the .NET Forum. Thanks.
May 27 '08 #2
imtmub
112 100+
Dr B
First of all I have to say thanks for ur response.
When i check the Source html genreted by my code My Textbox1 id change to "ctl00_ContentPlaceHolder1_TextBox1"

Then I have modified my java function according to your suggestion. Still i am facing the same problem. The Textbox is not transfering data to parent page textbox. Can u see anyother info i need to change?

Thanks
May 28 '08 #3
DrBunchman
979 Expert 512MB
Can you show me the code you're using now on each page please?

Thanks,

Dr B
May 28 '08 #4
imtmub
112 100+
Can you show me the code you're using now on each page please?

Thanks,

Dr B
Parent Page:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="True"></asp:TextBox>
  3. <a href="#" onclick="OpenNewWindow()">Lookup</a>
  4. function OpenNewWindow() 
  5. {
  6.  
  7. window.open('ChildMain.aspx?txt=<%=TextBox1.ClientID%>','MyPopUp','width=500,height=700,scrollbars=1,resizable=1');
  8. }
  9.  
ChildMain:
Expand|Select|Wrap|Line Numbers
  1.  
  2. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  3. <input id="Button2" onclick="Transfer()" type="button" value="Select" style="width: 65px" />
  4.  
  5. function Transfer() 
  6. {
  7. window.opener.form1.TextBox1.value = document.getElementById('" & Request.Querystring("txt") & "').value;
  8. window.close(); 
  9. }
  10.  
Thanks
May 29 '08 #5
DrBunchman
979 Expert 512MB
I can't see anything obvious - can you check the value that is passed in the querystring and compare it the actual ID from your mark-up. Are they the same?
May 29 '08 #6
imtmub
112 100+
I can't see anything obvious - can you check the value that is passed in the querystring and compare it the actual ID from your mark-up. Are they the same?
I have checked. I m going to leave this wndow.opener.
Do you any other method that i can post back value
May 29 '08 #7
imtmub
112 100+
I have checked. I m going to leave this wndow.opener.
Do you any other method that i can post back value
I dont know where i m doing wrong. if ou have any demo page that will be great help
May 29 '08 #8
imtmub
112 100+
I dont know where i m doing wrong. if ou have any demo page that will be great help
Please i wana complete this form with in this week. please help me to transfer data from child page text box to parent page text box.
I have tried java funstion is not working out for me. If you any vb script or demo page that will be great help.
May 30 '08 #9
imtmub
112 100+
Please i wana complete this form with in this week. please help me to transfer data from child page text box to parent page text box.
I have tried java funstion is not working out for me. If you any vb script or demo page that will be great help.
I m waiting answer. Please help me out
May 30 '08 #10
kunal pawar
297 100+
Please do not use form1 in Transfer method

this may helps you

document.opener.document.getElementById("Text1").v alue = document.getElementById("text1").value;




modify ur code and let me know updates
May 30 '08 #11
imtmub
112 100+
Please do not use form1 in Transfer method

this may helps you

document.opener.document.getElementById("Text1").v alue = document.getElementById("text1").value;




modify ur code and let me know updates
I have modified as per ur suggestion. But still its same
May 30 '08 #12
Frinavale
9,735 Expert Mod 8TB
I have modified as per ur suggestion. But still its same
I'm not the greatest with JavaScript but I'm almost 100% sure that you cannot transfer data between a child and parent browser.

You will have to try and use the server to transfer the data.
The problem is that after your child window is finished, the parent one will have no idea that this has happened and the server has no way to indicate to the parent browser that there is updated data waiting for it.

I would suggest placing the content of your child window inside a <div> that can be positioned to display as if it were floating in front of the parent data. Remember that asp Panels are rendered as <div>'s. That way your "parent" will have access to the data in the "child"...the only difference is that you aren't using 2 browsers.


-Frinny
May 30 '08 #13
imtmub
112 100+
I'm not the greatest with JavaScript but I'm almost 100% sure that you cannot transfer data between a child and parent browser.

You will have to try and use the server to transfer the data.
The problem is that after your child window is finished, the parent one will have no idea that this has happened and the server has no way to indicate to the parent browser that there is updated data waiting for it.

I would suggest placing the content of your child window inside a <div> that can be positioned to display as if it were floating in front of the parent data. Remember that asp Panels are rendered as <div>'s. That way your "parent" will have access to the data in the "child"...the only difference is that you aren't using 2 browsers.


-Frinny
I have place my function inside <div></div> but still its acting same. I m not getting what i want.
Jun 2 '08 #14
kunal pawar
297 100+
can u check

Expand|Select|Wrap|Line Numbers
  1.  
  2. document.opener.document.getElementById("Text1").value = document.getElementById("text1").value;
  3.  
  4. alert("Val 1 : " + document.getElementById("text1").value); 
  5. alert("Val 2 : " + document.opener.document.getElementById("Text1").value);
  6.  
Jun 2 '08 #15
Frinavale
9,735 Expert Mod 8TB
I have place my function inside <div></div> but still its acting same. I m not getting what i want.
Are you using AJAX?
Do you have your "child" object within one UpdatePanel and your parent in another? If this is the case, then your parent will be refreshed with old data.....

-Frinny
Jun 2 '08 #16
DrBunchman
979 Expert 512MB
I'm not the greatest with JavaScript but I'm almost 100% sure that you cannot transfer data between a child and parent browser.
If that's the case then how come this:
Expand|Select|Wrap|Line Numbers
  1. document.opener.document.getElementById("TextBox1").value = 'Hello World!'; window.close();
  2.  
works as a method of passing data back from child window to parent? I've used this method successfully to pass data back from calendar pop-ups and the like many times and I can't see how, with this being client-side JS, it could be passing it through the server rather than the browser.

I could, of course, be completely wrong and I would be interested if anybody knew how this worked.

Dr B
Jun 2 '08 #17
imtmub
112 100+
Are you using AJAX?
Do you have your "child" object within one UpdatePanel and your parent in another? If this is the case, then your parent will be refreshed with old data.....

-Frinny
My website is not AJAX enabled. I m not using AJAX. So i dont have update panel on my pages.
Jun 3 '08 #18
DrBunchman
979 Expert 512MB
imtmub,

Have you managed to get this sorted yet?

Dr B
Jun 4 '08 #19
Frinavale
9,735 Expert Mod 8TB
imtmub,

Have you managed to get this sorted yet?

Dr B
If not, could you please post any code that is relevant to this problem so that we can figure out what is wrong.

-Frinny
Jun 4 '08 #20
imtmub
112 100+
imtmub,

Have you managed to get this sorted yet?

Dr B
Yes.Finally decided not to use Master page. Instead of master page i have created user controls then placed on my pages. Anyhave i m really appriciating all of you people for the answers.
Jun 6 '08 #21
imtmub
112 100+
If not, could you please post any code that is relevant to this problem so that we can figure out what is wrong.

-Frinny
Hello Frinavale,
I have solved using user controls instead of master page.

Anyhave lets have a try if u can solve the master page issue.

Here my parent Page(SingleLevelN.aspx). This page is master page enabled.
Expand|Select|Wrap|Line Numbers
  1.  
  2. %@ Page Language="VB" MasterPageFile="~/aspx/MasterPage.master" AutoEventWireup="false" CodeFile="SingleLevelN.aspx.vb" Inherits="aspx_SingleLevelN" title="Report-SingleLevelBOM" %>
  3.  
  4. <%@ Register Assembly="CrystalDecisions.Web, Version=10.2.3600.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
  5. Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
  6. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  7. SelectParentId<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><a href="#"
  8. onclick="OpenNewWindow()">Lookup</a>
  9. <asp:Button ID="Button1" runat="server" Text="Button" /><br />
  10. <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
  11. EnableParameterPrompt="False" ReportSourceID="CrystalReportSource1" />
  12. <CR:CrystalReportSource ID="CrystalReportSource1" runat="server">
  13. <Report FileName="BOM1.rpt">
  14. <Parameters>
  15. <CR:ControlParameter ControlID="TextBox1" ConvertEmptyStringToNull="False" DefaultValue=""
  16. Name="ParentId" PropertyName="Text" ReportName="" />
  17. </Parameters>
  18. </Report>
  19. </CR:CrystalReportSource>
  20. <script language="javascript" type="text/javascript">
  21.  
  22. function OpenNewWindow() 
  23. {
  24. window.open('ChildMain.aspx','MyPopUp','width=500,height=700,scrollbars=1,resizable=1');
  25. }
  26.  
  27. </script>
  28.  
  29. </asp:Content>
  30.  
Child Page(Childmain.aspx).
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="ChildMain.aspx.vb" Inherits="aspx_ChildMain" %>
  3.  
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  5.  
  6. <html xmlns="http://www.w3.org/1999/xhtml" >
  7. <head runat="server">
  8. <title>Untitled Page</title>
  9. <script type="text/javascript">
  10. function Transfer() 
  11. {
  12. //window.opener.form1.TextBox1.value = document.getElementById('" & Request.Querystring("txt") & "').value;
  13. window.opener.document.forms[0].Textbox1.value = document.getElementById("Textbox1").value;
  14.  
  15. window.close(); 
  16. }
  17. </script>
  18. </head>
  19. <body>
  20. <form id="form1" runat="server">
  21. <div>
  22. Select Query Type
  23. <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal"
  24. Width="173px">
  25. <asp:ListItem Selected="True" Value="ItemId">ItemId</asp:ListItem>
  26. <asp:ListItem>ItemName</asp:ListItem>
  27. </asp:RadioButtonList>Enter the Item
  28. <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
  29. <asp:Button ID="Button1" runat="server" Text="Find" Width="68px" />
  30. &nbsp;<input id="Button2" onclick="Transfer()" type="button" value="Select" style="width: 65px" /><br />
  31. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="font-size: 9pt">
  32. &nbsp; &nbsp; &nbsp; &nbsp; Example(11001% or 316%8)<asp:GridView ID="GridView1"
  33. runat="server" AutoGenerateColumns="False" DataKeyNames="ItemID" DataSourceID="SqlDataSource1"
  34. Font-Names="Times New Roman" Font-Size="11pt" Width="463px">
  35. <Columns>
  36. <asp:CommandField ShowSelectButton="True">
  37. <ItemStyle Width="85px" />
  38. <ControlStyle Font-Size="Medium" />
  39. </asp:CommandField>
  40. <asp:BoundField DataField="ItemID" HeaderText="ItemID" ReadOnly="True" SortExpression="ItemID">
  41. <ItemStyle Width="85px" />
  42. </asp:BoundField>
  43. <asp:BoundField DataField="ItemName" HeaderText="ItemName" SortExpression="ItemName" />
  44. </Columns>
  45. </asp:GridView>
  46. </span><br />
  47. <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:IERP52ConnectionString3 %>"
  48. SelectCommand="If @QryType='ItemId' Begin Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima where (ima_itemid LIKE @IMA_ItemID) end Else Begin Select top 1000 ima_itemid as ItemID, ima_itemName as ItemName from ima where (ima_itemname LIKE @IMA_ItemID) end ">
  49. <SelectParameters>
  50. <asp:ControlParameter ControlID="RadioButtonList1" Name="QryType" PropertyName="SelectedValue" />
  51. <asp:ControlParameter ControlID="TextBox1" Name="IMA_ItemID" PropertyName="Text" />
  52. </SelectParameters>
  53. </asp:SqlDataSource>
  54. &nbsp;&nbsp;&nbsp;
  55. </div>
  56. </form>
  57. </body>
  58. </html>
  59.  
-------------------------------------
I have tried all the solution given in this forum. Finally i m ended with this code. But all the code results are same. not giving any result.

Anyhave thanks for showing interest to solve. It will be great help.
Jun 6 '08 #22

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

Similar topics

5
by: Tom | last post by:
Hi I am trying to transfer to a different .ASPX page using Server.Transfer. However, I get the following error: "Error executing child request for .aspx." Anyone know why? Thanks for...
5
by: Julien C. | last post by:
Hi all, I have an "EditeItem.aspx" page which lets me edit properties of an "Item". In the OnClick() event of my Save button, I do save Item changes to the database and then I redirect the user...
0
by: Amar | last post by:
After using Server.Transfer to transfer data from one page to another, I would like to know if there is a way to keep the receiving web page variables intact after a postback. Here is the code...
2
by: Mr Wizard | last post by:
I am going through the front controller http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpFrontControllerInASP.asp and all works well except when the server.transfer...
1
by: Terry Mulvany | last post by:
Grettings, Normally I can use Request.RawUrl to get the 'current' page (amongst many other things). But in the case of using a Server.Transfer but the path from the root of the site . So if...
2
by: David Berman | last post by:
It seems that my site is losing session information when using Server.Transfer. I have a page called PictureGallery.aspx. It takes an argument which is an index id, so it would look like...
7
by: dee | last post by:
Inside Search.aspx I make the following call: Server.Transfers("Table.aspx"); I'm transfered to Table.aspx and browser still shows Search.aspx in address bar. However, I do postback within...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
4
by: evantay | last post by:
I'm using ASP.NET 2.0 with VS.NET 2005. I'm trying to access properties from my master pages within a page that inherits from that master page (a child page). However the values are always null....
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.