By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,376 Members | 1,566 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,376 IT Pros & Developers. It's quick & easy.

Updating the parent page after the child page closes...

P: 45
Hi there,

I have a problem. I am devloping a C# ASP.NET User Control (a .ascx file). I want to display a table on the user control. This table is generated on the fly. First the user control displays a Panel (<asp:Panel />) asking the user to enter the noumer of rows and columns. It also provides the user with a link button (asp:LinkButton />). When the user clicks the link button the panel disappears and a new panel is displayed with the specified number of rows and columns. This of course is handled in the "IsPostBack" part of the Page_Load. That means, I check for the condition whether the page is posted back and then create the table with the Table t = new Table();, TableRow tr = new TableRow(); and TableCell tc = new Table Cell();. Ihave two for loops (one inside the other) for costructing the table. That is, I create as many cells (columns) for every row that that the user specified.

Now, I have assigned a javascript to all of the cells like this....

tc.Attributes.Add("onclick", "javascript:window.open(add.aspx, 'Add' , 'width=500, height=500, resizable=yes'");

Now, my problem is, when this child window closes I want to use the text entered in the Text box (in the child window) to be added to the respective cell that was clicked and that too without a postback. Because if I postback the table will be created all over again causing all data to be lost.

In short,

1] I want to somehow use/pass the vatiable/value to the parent page from the child page.
2] I want to update the table cell without a postback.

I thank you all,

Regards.
Feb 28 '07 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
When opening the window, send a reference to the child window, e.g. "add.aspx?id=td1". Then you can use this id to ref. the table cell that the iuse clicked on. One way to get this id is to use:
Expand|Select|Wrap|Line Numbers
  1. "add.aspx" + this.id
Then in the child window, use
Expand|Select|Wrap|Line Numbers
  1. window.opener.document.getElementById(id)
to refer to the table cell. Use the innerHTML property to change the table cell and you're done!
Feb 28 '07 #2

P: 45
When opening the window, send a reference to the child window, e.g. "add.aspx?id=td1". Then you can use this id to ref. the table cell that the iuse clicked on. One way to get this id is to use:
Expand|Select|Wrap|Line Numbers
  1. "add.aspx" + this.id
Then in the child window, use
Expand|Select|Wrap|Line Numbers
  1. window.opener.document.getElementById(id)
to refer to the table cell. Use the innerHTML property to change the table cell and you're done!
Does not appear to work.

Ok. I need a way to preserve the controls i create even if I postback. I mean, I visit the page - enter the no of row and the no of columns. Click a link button which causes to post back. I test, in the Page_Load to see whether it is a postback, if it is I generate dynamic controls that represent the table. [Table, TableCell(s), TableRow(s)]. Now after that I need to again post back but I don't want to loose the dynamically created controls. Is there a way to preserve the dynamically created controls and their values over postbacks??

Please help.

Regards.
Mar 1 '07 #3

acoder
Expert Mod 15k+
P: 16,027
Does not appear to work.
Post your code.
Mar 1 '07 #4

Post your reply

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