Updating parent window from popup

Discussion in 'ASP .Net' started by mkobus, Jul 23, 2003.

  1. mkobus

    mkobus Guest

    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!
    mkobus, Jul 23, 2003
    #1
    1. Advertising

  2. Hi

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

    --
    Best Regards
    Vidar Petursson
    ==============================
    Microsoft Internet Client & Controls MVP
    ==============================
    "mkobus" <> wrote in message
    news:...
    > 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!
    Vidar Petursson, Jul 23, 2003
    #2
    1. Advertising

  3. mkobus

    Marina Guest

    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" <> wrote in message
    news:...
    > 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!
    Marina, Jul 23, 2003
    #3
  4. mkobus

    Marina Guest

    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" <> wrote in message
    news:...
    > Just out of curiosity.
    >
    > Wouldn't window.opener.document.Form1.submit() work?
    >
    > Reddy
    >
    >
    > "Marina" <> wrote in message
    > news:%23VI$...
    > > 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" <> wrote in message
    > > news:...
    > > > 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!

    > >
    > >

    >
    >
    Marina, Jul 23, 2003
    #4
  5. mkobus

    Paul Hobbs Guest

    Re: Updating parent window from popup - Question for Saravana

    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" <> wrote in message
    news:e#...
    > Check out this article,
    > http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx
    >
    > --
    > Saravana
    > Microsoft India Community Star,
    > MCAD,SE,SD,DBA.
    >
    >
    > "mkobus" <> wrote in message
    > news:...
    > > 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!

    >
    >
    Paul Hobbs, Jul 25, 2003
    #5
  6. mkobus

    Saravana Guest

    Re: Updating parent window from popup - Question for Saravana

    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" <> wrote in message
    news:uZ#...
    > 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" <> wrote in message
    > news:e#...
    > > Check out this article,
    > > http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx
    > >
    > > --
    > > Saravana
    > > Microsoft India Community Star,
    > > MCAD,SE,SD,DBA.
    > >
    > >
    > > "mkobus" <> wrote in message
    > > news:...
    > > > 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!

    > >
    > >

    >
    >
    Saravana, Jul 25, 2003
    #6
  7. mkobus

    Paul Hobbs Guest

    Re: Updating parent window from popup - Question for Saravana

    Hi Saravana,

    I actually managed to solve this problem by using a technique in another of
    your articles
    (www.microsoft.com/india/msdn/articles/SolutionstoTopFourQuestions.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" <> wrote in message
    news:#...
    > 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" <> wrote in message
    > news:uZ#...
    > > 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" <> wrote in message
    > > news:e#...
    > > > Check out this article,
    > > > http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx
    > > >
    > > > --
    > > > Saravana
    > > > Microsoft India Community Star,
    > > > MCAD,SE,SD,DBA.
    > > >
    > > >
    > > > "mkobus" <> wrote in message
    > > > news:...
    > > > > 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!
    > > >
    > > >

    > >
    > >

    >
    >
    Paul Hobbs, Jul 25, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob
    Replies:
    4
    Views:
    1,175
    Vidar Petursson
    Jun 5, 2004
  2. Earl Teigrob
    Replies:
    1
    Views:
    5,837
    Earl Teigrob
    Jun 16, 2004
  3. chuckdfoster

    Send Info From PopUp Window To Parent Window

    chuckdfoster, Dec 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    712
    =?Utf-8?B?SmVk?=
    Dec 6, 2005
  4. Jason Wilson
    Replies:
    2
    Views:
    5,362
    Jason Wilson
    Sep 15, 2006
  5. Chandra
    Replies:
    0
    Views:
    640
    Chandra
    Apr 12, 2007
Loading...

Share This Page