Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Updating parent window from popup

Reply
Thread Tools

Updating parent window from popup

 
 
mkobus
Guest
Posts: n/a
 
      07-23-2003
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!
 
Reply With Quote
 
 
 
 
Vidar Petursson
Guest
Posts: n/a
 
      07-23-2003
Hi

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

--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"mkobus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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!



 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      07-23-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) 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!



 
Reply With Quote
 
Marina
Guest
Posts: n/a
 
      07-23-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Just out of curiosity.
>
> Wouldn't window.opener.document.Form1.submit() work?
>
> Reddy
>
>
> "Marina" <(E-Mail Removed)> wrote in message
> news:%23VI$(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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!

> >
> >

>
>



 
Reply With Quote
 
Paul Hobbs
Guest
Posts: n/a
 
      07-25-2003
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" <(E-Mail Removed)> wrote in message
news:e#(E-Mail Removed)...
> Check out this article,
> http://www.microsoft.com/india/msdn/...ndarinASP.aspx
>
> --
> Saravana
> Microsoft India Community Star,
> MCAD,SE,SD,DBA.
>
>
> "mkobus" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) 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!

>
>



 
Reply With Quote
 
Saravana
Guest
Posts: n/a
 
      07-25-2003
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" <(E-Mail Removed)> wrote in message
news:uZ#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:e#(E-Mail Removed)...
> > Check out this article,
> > http://www.microsoft.com/india/msdn/...ndarinASP.aspx
> >
> > --
> > Saravana
> > Microsoft India Community Star,
> > MCAD,SE,SD,DBA.
> >
> >
> > "mkobus" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) 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!

> >
> >

>
>



 
Reply With Quote
 
Paul Hobbs
Guest
Posts: n/a
 
      07-25-2003
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:uZ#(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:e#(E-Mail Removed)...
> > > Check out this article,
> > > http://www.microsoft.com/india/msdn/...ndarinASP.aspx
> > >
> > > --
> > > Saravana
> > > Microsoft India Community Star,
> > > MCAD,SE,SD,DBA.
> > >
> > >
> > > "mkobus" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) 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!
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Iframe window updating parent window property? Chandra HTML 0 04-12-2007 10:39 AM
Updating Parent TextBox from Child Popup Window Jason Wilson ASP .Net 2 09-15-2006 09:25 PM
Send Info From PopUp Window To Parent Window chuckdfoster ASP .Net 1 12-06-2005 08:00 PM
Solution: Raising an Event Handler Postback on Parent Window From Popup Child Window Dialog Box Earl Teigrob ASP .Net 1 06-16-2004 04:19 PM
Popup window to raise event in parent window...can it be done??? Earl Teigrob ASP .Net 4 06-04-2004 11:47 PM



Advertisments