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

Updating parent window from popup

P: n/a
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!
Nov 17 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Hi

window.opener.document.forms[0].myButton.click();

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!

Nov 17 '05 #2

P: n/a
Maybe something like: window.opener.document.Form1.Button1.click()

Worse case, create a javascript function in the parent that causes the
button to click, and call the function from your child window.

"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!

Nov 17 '05 #3

P: n/a
That's a little different then actually causing the click event of a button.
If you submit the form, how do you know server side which button submitted
it? I don't think the right button click event handler would be able to run.

"Srinivasa Reddy K Ganji" <gk******@adsgroup.com> wrote in message
news:ed**************@TK2MSFTNGP11.phx.gbl...
Just out of curiosity.

Wouldn't window.opener.document.Form1.submit() work?

Reddy
"Marina" <zl*******@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Maybe something like: window.opener.document.Form1.Button1.click()

Worse case, create a javascript function in the parent that causes the
button to click, and call the function from your child window.

"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!



Nov 17 '05 #4

P: n/a
Hi Saravana,

I have looked at your article and the popup calendar works perfectly.
Thankyou! But, I am having a problem using it in a datagrid.

I can place the CalendarUserControl in the ItemTemplate of the datagrid, and
it works as expected when I am editing a particular row of the grid. But, I
am having difficulty binding the user control so that it displays the
current value of that field.

For example, the datagrid is bound to a table of customers, and one column
is the customer's birthday. When the page loads, all the birthdays are
displayed. When I click Edit, I want the CalendarUserControl to show the
birthday for the customer in that row. But at the moment, it is just blank.

Any advice you can give would be greatly appreciated.

Cheers,

Paul Hobbs

PS: I downloaded the source code from your article below, and the datagrid
example doesn't work because the zip file doesn't include the Products.xml
file. Are you perhaps able to create a datagrid example that uses your
CalendarUserControl, but where the datagrid is bound to NorthWind.Orders,
and the CalendarUserControl is bound to Orders.RequiredDate. ;-)

"Saravana" <sa******@sct.co.in> wrote in message
news:e#**************@TK2MSFTNGP10.phx.gbl...
Check out this article,
http://www.microsoft.com/india/msdn/...ndarinASP.aspx

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!


Nov 17 '05 #5

P: n/a
Hi paul,

I tried in datagrid, it is working fine for me. I didnt send the
products.xml with my source code if you want i will send it to you. you
place it in d:\ or change the source code to read that file from specific
location. Use "TextValue" property of the user control to set the default
value for Calendar control. If you want more detail on this, get back to me.

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.

PS: I have sent products.xml to your personal account

"Paul Hobbs" <pa**@mobius.net.au> wrote in message
news:uZ*************@TK2MSFTNGP09.phx.gbl...
Hi Saravana,

I have looked at your article and the popup calendar works perfectly.
Thankyou! But, I am having a problem using it in a datagrid.

I can place the CalendarUserControl in the ItemTemplate of the datagrid, and it works as expected when I am editing a particular row of the grid. But, I am having difficulty binding the user control so that it displays the
current value of that field.

For example, the datagrid is bound to a table of customers, and one column
is the customer's birthday. When the page loads, all the birthdays are
displayed. When I click Edit, I want the CalendarUserControl to show the
birthday for the customer in that row. But at the moment, it is just blank.
Any advice you can give would be greatly appreciated.

Cheers,

Paul Hobbs

PS: I downloaded the source code from your article below, and the datagrid example doesn't work because the zip file doesn't include the Products.xml
file. Are you perhaps able to create a datagrid example that uses your
CalendarUserControl, but where the datagrid is bound to NorthWind.Orders,
and the CalendarUserControl is bound to Orders.RequiredDate. ;-)

"Saravana" <sa******@sct.co.in> wrote in message
news:e#**************@TK2MSFTNGP10.phx.gbl...
Check out this article,
http://www.microsoft.com/india/msdn/...ndarinASP.aspx

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
Im relatively new, so please be patient with me...

I need to update a parent .aspx screen from a popup and close the
popup. Normally I would use
'window.opener.location.reload(true);self.close(); ' but i need the
parent window not to reload or else data that the user has already
entered will be lost during the IsPostBack.

I need the 'Apply' button on the popup to trigger the 'Update' button
on the parent screen. The script ive seen is like this...
'window.opener.location.Form1.Button1.Click(); self.close();' but I
get a Javascript Error that reads
'window.opener.location.Form1.Button1' is null or not an object.

Any thoughts? Ive seen other posts that say to make sure Button1 on
Form1 is within the <form> tags and it is. Any help would be
appreciated!



Nov 17 '05 #6

P: n/a
Hi Saravana,

I actually managed to solve this problem by using a technique in another of
your articles
(http://www.microsoft.com/india/msdn/...uestions.aspx). I
simply borrowed the same technique for preselecting an item in a DDL, and
applied it to the textfield property of the user control, and it works like
a charm.

BUT, I have a new error now!

I have included my code for the ItemDataBound event below:

This code works fine, until I click the Update button in the datagrid, and
then I get an error

Private Sub grdAlbums_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles
grdAlbums.ItemDataBound

If e.Item.ItemType = ListItemType.EditItem Then

Dim drv As DataRowView = CType(e.Item.DataItem, DataRowView)

'get current values

Dim currentArtist As String = CType(drv("ArtistName"), String)

Dim currentDate As String

If drv("AlbumReleaseDate") Is DBNull.Value Then

currentDate = ""

Else

currentDate = CType(drv("AlbumReleaseDate"), String)

End If

'preselect correct item in DDL

Dim ddl As DropDownList

ddl = CType(e.Item.FindControl("lstArtists_edit"), DropDownList)

ddl.Items.FindByText(currentArtist).Selected = True

'set value of text field in Calendar control

Dim ucCal As CalendarUserControl

ucCal = CType(e.Item.FindControl("calRelDate_edit"), CalendarUserControl)

ucCal.TextValue = currentDate

End If

End Sub

This code works fine when I click the Edit button. But after I edit a
field, and click the Update button, I get this error:

Object reference not set to an instance of an object.

And the line of code that trips the error is this:
Line 336: ddl.Items.FindByText(currentArtist).Selected = True

I think I know why this is happening (when the grid goes back to display
mode, the DDL object no longer exists), but I don't know how to fix it.

Thanks for your help!

Cheers,

Paul


"Saravana" <sa******@sct.co.in> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
Hi paul,

I tried in datagrid, it is working fine for me. I didnt send the
products.xml with my source code if you want i will send it to you. you
place it in d:\ or change the source code to read that file from specific
location. Use "TextValue" property of the user control to set the default
value for Calendar control. If you want more detail on this, get back to me.
--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.

PS: I have sent products.xml to your personal account

"Paul Hobbs" <pa**@mobius.net.au> wrote in message
news:uZ*************@TK2MSFTNGP09.phx.gbl...
Hi Saravana,

I have looked at your article and the popup calendar works perfectly.
Thankyou! But, I am having a problem using it in a datagrid.

I can place the CalendarUserControl in the ItemTemplate of the datagrid, and
it works as expected when I am editing a particular row of the grid. But, I
am having difficulty binding the user control so that it displays the
current value of that field.

For example, the datagrid is bound to a table of customers, and one

column is the customer's birthday. When the page loads, all the birthdays are
displayed. When I click Edit, I want the CalendarUserControl to show the birthday for the customer in that row. But at the moment, it is just

blank.

Any advice you can give would be greatly appreciated.

Cheers,

Paul Hobbs

PS: I downloaded the source code from your article below, and the

datagrid
example doesn't work because the zip file doesn't include the Products.xml file. Are you perhaps able to create a datagrid example that uses your
CalendarUserControl, but where the datagrid is bound to NorthWind.Orders, and the CalendarUserControl is bound to Orders.RequiredDate. ;-)

"Saravana" <sa******@sct.co.in> wrote in message
news:e#**************@TK2MSFTNGP10.phx.gbl...
Check out this article,
http://www.microsoft.com/india/msdn/...ndarinASP.aspx

--
Saravana
Microsoft India Community Star,
MCAD,SE,SD,DBA.
"mkobus" <tu******@hotmail.com> wrote in message
news:2c**************************@posting.google.c om...
> Im relatively new, so please be patient with me...
>
> I need to update a parent .aspx screen from a popup and close the
> popup. Normally I would use
> 'window.opener.location.reload(true);self.close(); ' but i need the
> parent window not to reload or else data that the user has already
> entered will be lost during the IsPostBack.
>
> I need the 'Apply' button on the popup to trigger the 'Update' button > on the parent screen. The script ive seen is like this...
> 'window.opener.location.Form1.Button1.Click(); self.close();' but I
> get a Javascript Error that reads
> 'window.opener.location.Form1.Button1' is null or not an object.
>
> Any thoughts? Ive seen other posts that say to make sure Button1 on
> Form1 is within the <form> tags and it is. Any help would be
> appreciated!



Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.